동적으로 이런 코드 tablerows 체크 박스를 만듭니다의 생성 후작업은
for (Iterator i = users.iterator(); i.hasNext();) {
Users p = (Users) i.next();
/** Create a TableRow dynamically **/
tr = new TableRow(this);
/** Creating a Checkbox to add to the row **/
CheckBox cb = new CheckBox(this);
cb.setText(p.getEan());
LinearLayout Ll1 = new LinearLayout(this);
Ll1.addView(cb);
System.out.println(j);
tr.addView((View)Ll1); // Adding CheckBox to tablerow.
/** Creating a TextView to add to the row **/
label = new TextView(this);
label.setText(p.getName());
label.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
label.setPadding(5, 5, 5, 5);
label.setBackgroundColor(Color.GRAY);
LinearLayout Ll = new LinearLayout(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
params.setMargins(5, 2, 2, 2);
Ll.addView(label,params);
tr.addView((View)Ll); // Adding textView to tablerow.
// Add the TableRow to the TableLayout
tl.addView(tr, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
사용자를 확인하거나 취소 할 수 있습니다. 수표로 모든 체크 박스에 대해 다른 명령을 실행해야합니다.
내 문제는 어떻게 확인란을 사용합니까? 내가 어떻게 "말할"수있어서 그것으로 작업 할 수 있습니까?
'모든 체크 박스마다 다른 명령을 실행'하고 싶을 때 ?? –
@hevilp onCheckedChangeListener 메소드에 소스를 게시하십시오. – iRuth
다른 명령은 확인란의 텍스트를 기반으로해야합니까? – Salmaan