I have 20 static checkboxes, clicking on one of them executes a function through onClick
. But this is perhaps a stupid question but how do I know exactly which of the 20 checkboxes it was clicked on? I already have if
that checks if any of the 20 checkboxes are clicked through isChecked()==true
but it does not tell me if it was checkbox a, b, or c.
I saw this solution
switch (v.getId()) {
case R.id.Checkboxes_1 :
break;
case R.id.Checkboxes_2 :
break;
case R.id.Checkboxes_3 :
break;}
But then if I have 20 checkboxes, will I have to do 20 cases ?! Is not there a different way?