1

I have a list of emotion icons(over 100 icons).
And I would like to display in a view that people can click it and toast what he is clicking.
emotion icons Now, I have some confusing points:
1) What views should I use to include all this icons (GridView or ListView)?
2) How to dynamic add them or add them pro-grammatically? If I declare each one by one, I think it is no good. But any other ideas?
All the images icons is in drawable folder. Thanks.

jjLin
  • 3,281
  • 8
  • 32
  • 55

1 Answers1

3

GridView would be better in this case with a PopupWindow. Take a HashMap and store the name of the smiley as String and its Image as Resource Id.

eg:-

HashMap<String, Integer> map = new  HashMap<String, Integer>();
map.put("smile", R.drawable.smile);
.... 

Now, Iterate through all the values(images) of HashMap and poplulate your GridView from the HashMap values(images).

And, inside Adapter class you can show images using map.get(key); to ImageView and set the Resource.

UPDATE:

I had just created a small demo for the same you can check it from here.

Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242