2012-04-03 10 views
0

膨らんだテーブルからボタンのタグを取得するにはどうすればよいですか?これまでのところ、次のコードがあります。ボタンを押すと、ボタンからタグを取得する方法は?膨大なAndroidテーブルからボタンのタグを取得するにはどうすればよいですか?

TableLayout table = (TableLayout)findViewById(R.id.scheduleTable); 
for (int i = 0; i < jlen; i++) { 

    // Inflate 
    TableRow row = (TableRow)LayoutInflater.from(UpdateScheduleActivity.this).inflate(R.layout.schedulerow, null); 
    ((TextView)row.findViewById(R.id.attr_day)).setText(json_schedule.getString(KEY_DOW)); 
    ((TextView)row.findViewById(R.id.attr_start)).setText(json_schedule.getString(KEY_START)); 
    ((TextView)row.findViewById(R.id.attr_stop)).setText(json_schedule.getString(KEY_STOP)); 
    ((Button)row.findViewById(R.id.btnRemove)).setTag(sid); 
    table.addView(row); 

} 
table.requestLayout(); 

答えて

0

あなたはByteMeが言ったように、そこからちょうど()

0

view.getTagを使用し、あなたのonItemClickまたはonClickListenerでボタンへの参照を取得する必要がありますが、あなたはボタンのonClickListenerを設定する必要があります。そのような何かが動作する可能性があり:あなたのケースで

((Button)row.findViewById(R.id.btnRemove)).setOnClickListener(new OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     ((Button) v).getTag(); 
     // Do whatever you like when the button is pressed. 
    } 
}); 
1

btn = (Button)**row**.findViewById(R.id.btnRemove); 

はこれがあなた

役立つことを願っています
関連する問題