I have checkboxes that are created dynamically, and I want to press a button a check them all. The button I metioned is located in toolbar and this is the code from it:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_checkall:
return true;
Then I have a table row inside a table layout and this is the code from the table row where I create the checboxes
final TableRow row = new TableRow(getApplicationContext());
row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
String[] colText={numerochip};
String[] colText2={marcaexploracao,marcaauricular,datanascimento};
for(final String text:colText) {
final CheckBox ch = new CheckBox(this);
ch.setTextColor(Color.parseColor("#808080"));
ch.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT));
ch.setGravity(Gravity.CENTER);
ch.setTextSize(16);
ch.setPadding(5, 5, 5, 5);
ch.setText(text);
row.addView(ch);
So I want to know, how to check all the cheboxes with a click of a button. Thanks
Aucun commentaire:
Enregistrer un commentaire