¿Cómo mostrar más imágenes después de hacer clic en el elemento Lista en Android?

I want to display the List items in List View and after click on any list item wants to load the around 50 images from resource folder.for each List item click i want to show the different set of images.

Which is the best way to proceed?

preguntado el 22 de septiembre de 13 a las 04:09

1 Respuestas

You may want to look into this training tutorial in the android documentation: http://developer.android.com/training/displaying-bitmaps/index.html

This will help in displaying images quickly and without memory issues.

As for the approach, it depends on the type of your listview and its contents,

  1. If its items are dynamic and large in number then you may want to have database table linking your list item index with your resource images (image names). You can then feed these into an adapter on clicking list item (onItemClick) to be displayed. Mostly images are best displayed in a GridView.

  2. If the number is small and static, you can have a two dimensional array of the list item index and the images in your resource folder.

Espero que esto ayude.

Respondido el 22 de Septiembre de 13 a las 06:09

I want to display different set of 50 images for each List item click.So How to store all the images in database?Can you post sample code? - Chait

You dont want to duplicate your images, since you said they are resource files, it will already be part of the apk, there is no need to insert these images into a database. You want to insert the linkage between the list item index and the image file name into the database i.e., Column 1 - list item index; Column 2 - image file name (or path); When you click on the list item you can look into the database for the image file names that are linked to this index, then display those images accordingly. what part do you need the code for, be specific , i can help out there. - Gurú

I just want to display the images in grid view.I have 3 items in the List View.For example,If i click on first item,want to show the some images in SampleActivity. If i click on second item from List View,want to show the different set of images in same SampleActivity.How to do that? - Chait

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.