2012-04-03 2 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); 

희망이 당신에게

도움이 될 것입니다
관련 문제