I'm trying to add an array of object in my class(MainActivity), for example
public class MainActivity extends Activity {
private class A {
A(String s) { ..}
}
private static final A[] aList1;
private static final List<A> aList2;
...
both are ok with me.
But I don't know how to initialize aList1 or aList2. Had already tried following:
private static final A[] aList;
static {
a = new A[2];
a[0] = new A("emails");
}
And also tried:
private static final List<A> aList = new ArrayList<A>(){{
add(new A("emails"));
}};
but eclipse are complaining: No enclosing instance of type MainActivity is accessible. Must qualify the allocation with an enclosing instance of type MainActivity (e.g. x.new A() where x is an instance of MainActivity).
How to fix this?