jeudi 14 juillet 2016

How to declare an array of checkboxes in android

I have googled this question but cannot find a simple or specific enough answer to it: Could any experienced programmer help me...?

I have an array of 10 checkboxes in a custom dialog called dialog1.

public class DigitsActivity extends Activity {
...
CheckBox[] ckbDigits = new CheckBox[10];
...


public void SelectDigit1(){  // method which opens the custom dialog

Context context=DigitsActivity.this;
final Dialog dialog1 = new Dialog(context);
...
for (int k = 0; k <= 9; k++){
  ckbDigits[k] = (CheckBox) dialog1.findViewById(R.id.ckbDigits[k]);
}
...
}

I am getting multiple errors at the line

ckbDigits[k] = ...

I tried also :

ckbDigits[] = (CheckBox) dialog1.findViewById(R.id.ckbDigits[]);

but it doesn't work either...

Could anybody tell me how to declare an array of checkboxes ?

Thanks.

Aucun commentaire:

Enregistrer un commentaire