I have a multiplechoice dialog on my activity. I have a boolean array to keep track of which items are selected from the dialog. So I want each time an item is clicked to make the corresponding place on my array true. The array is being created in the onCreateDialog before the return.

```
public Dialog onCreateDialog(int id) {
  userlistlocal=getuserlist(username);
  boolean[] usernamechecked=new boolean[userlistlocal.length/3];
  Arrays.fill(usernamechecked,false);         
  return new AlertDialog.Builder(Newevent.this)
        .setIcon(R.drawable.ic_menu_invite)
        .setTitle("Add People")
        .setMultiChoiceItems(userselectionlistlocal,
                null,new DialogInterface.OnMultiChoiceClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton,
                            boolean isChecked) { 

                        /* User clicked on a check box do some stuff */
                     usernamechecked[whichButton]=isChecked;<-------HERE
                    }
                })
        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                /* User clicked Yes so do some stuff */
            }
        })
        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                /* User clicked No so do some stuff */
            }
        })
       .create();

 }

```

But when I put in the onClick method my boolean array it says it has to be final(Cannot refer to a non-final variable usernamechecked inside an inner class defined in a different method). I dont know what to do