I am new to Java. I have runtime error at the line containing myImageViews[0].v1 = new ImageView(context). Is something wrong there?
class MyImageViews
{
ImageView v1;
ImageView v2;
}
MyImageViews[] myImageViews;
protected class MyLayout extends RelativeLayout {
public MyLayout(Context context) {
super(context);
myImageViews = new MyImageViews[10];
myImageViews[0].v1 = new ImageView(context); //runtime error at this line
}
}
You have created an array that can contain
MyImageViewsinstances but have not yet created an instance.myImageViews[0]is null.Try changing
to