I've been having trouble with some code lately:
public class SightsAdapter extends ArrayAdapter<Sights> {
static int mColorResourceId;
public SightsAdapter(ArrayList<Integer> sights, int colorResourceId) {
super(this, 0, sights);
mColorResourceId=colorResourceId;
}
}
I already tried using the static method in the Sights java class, but I still get the this underlined and an error message saying
cannot reference "this" before supertype constructor has been called
PS I already reviewed the other questions of this type and they didn't really help me . I'm a complete newbie here so if someone could explain to me what I'm doing wrong will be greatly appreciated.
It looks like you are confused as what to pass to the
superconstructor (belonging toArrayAdapter) as the first parameterContext.For example here you have an example, the main part is that:
Contextis something which must come from outside, yourSightsAdaptermust receive it as a parameter. That's the concept of context in applications: it is something which is injected from the environment in which the application/objects is running at the moment.