0

I would like to create a layout with many ImageView on it.

It should be an array of 10 pictures by 15 pictures. There is only 5 differents picture but I need to place them many time on this array.

Something like that but in 10 * 15 :

http://blazinggames.com/brain/puzzle/screenshots/cc.gif

So far, I am using a linear layout ( not sure it is the best choice Oo ) and I have this :

enter image description here

unsing this code :

LinearLayout linearLayout= new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);

linearLayout.setLayoutParams(new LayoutParams(
       LayoutParams.MATCH_PARENT,
       LayoutParams.MATCH_PARENT));


ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.green);
imageView.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
linearLayout.addView(imageView);
setContentView(linearLayout);

And I set an imageview1, imageview2, ... Each one with one of the 5 drawable I want ...

I know ! It is not the good way to code this ! It could work but it is very very long !

That is why I am here ^^

Can anyone help me ?

Thanks

3
  • 1
    You can use custom grid view. Commented Feb 14, 2014 at 17:29
  • You could have used a for loop to place your image view if the image chosen depends on the position. If this is not the case, so you have no way out but to manually code each. Commented Feb 14, 2014 at 17:35
  • Thanks guys but I dont know how to create a custom GridView neither to use a loop to set different drawable for different imageview, can you help me a little bit more ? Thanks ! Commented Feb 14, 2014 at 17:38

1 Answer 1

1

I have been able to make a gridview ! Thanks !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.