At the moment I have some test code that starts something like this:
CheckBoxPreference cb1 = new CheckBoxPreference(this);
CheckBoxPreference cb2 = new CheckBoxPreference(this);
What I want to achieve is an array of CheckBoxPreferences which I would expect to look something like this:
private CheckBoxPreference[] mFilterSubjects = new CheckBoxPreference(this)[24];
However, this generates an error "The type of the expression must be an array type but it resolved to CheckBoxPreference". The following code compiles correctly:
private CheckBoxPreference[] mFilterSubjects = new CheckBoxPreference[24];
However, if I try to do something with an element of the array, e.g. mFilterSubjects[0], I get a NullPointerException because there is no context.
How can I change my declaration to work properly, in other words, how do I declare each element of the array with context?