i have created a list of checkbox dynamically in my app..i want to detect which check box is clicked ...please help here is my code..
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_bid);
String[] sh=item_list();
int array_length=jArray.length();
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.lyout);
for(int c=0; c<jArray.length();c++){
CheckBox chk=new CheckBox(this);
chk.setId(c+1);
chk.setText("Click to add values");
chk.setTextColor(Color.GRAY);
linearLayout.addView(chk);
}
for(a = 1;a<=array_length;a++){
CheckBox satView = (CheckBox)findViewById(a);
satView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
String s="x"+a;
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
}
});
}
}