My problem is this. I have a number of ImageView objects in my XML layout. I want to be able to put images in to them deppending on some "if's" and "else's" (so to speak). So I thought I'd assign all those objects into an array. But the app wont start. Here is how I have done it:
private void setImageView(){
images = new ImageView[imagesNR];
images[0] = (ImageView) findViewById(R.id.imageView1);
images[1] = (ImageView) findViewById(R.id.imageView2);
images[2] = (ImageView) findViewById(R.id.ImageView01);
images[3] = (ImageView) findViewById(R.id.ImageView02);
images[4] = (ImageView) findViewById(R.id.ImageView03);
images[5] = (ImageView) findViewById(R.id.ImageView04);
images[6] = (ImageView) findViewById(R.id.ImageView05);
images[7] = (ImageView) findViewById(R.id.ImageView06);
images[8] = (ImageView) findViewById(R.id.ImageView07);
images[9] = (ImageView) findViewById(R.id.ImageView08);
images[10] = (ImageView) findViewById(R.id.ImageView09);
images[11] = (ImageView) findViewById(R.id.ImageView10);
}
I realize that's it's not the preatiest way, but since I'm new, that's what I came up with. I'm affraid I can't tell you too much about the error. The app is being forced closed and that's it.
Is there any other way I can have an array of ImageView and manipulate them accordingly?... I want to put the objects into an RelativeLayout and set where to put all those ImageViews etc, etc.
Edit:
private ImageView images[];
That's how I declared the array.