When creating a custom ListView
adapter, usually I extend it from Array Adapter<String>
but I want to make a ListView
containing photos from the Gallery of the phone.
I managed to get the Bitmap
from the Gallery referring to the picture the user chose and put it in a regular ImageView
but, I don't really know how to do an adapter of a ListView
displaying the photos the user choose. The photos are Bitmap
, any help?
You would do this exactly as you would do with a list that contains only text.
First you might want to create a class that represents an item in your list (maybe you want to add some more data, like an ID or a name), like:
Then just create a new class that extends ArrayAdapter:
Now you just need to create a layout that represents a row in your ListView. In this example you would likely add an ImageView (image) and a TextView (name) to a LinearLayout.
Then when you instanciate the adapter, just give it the layout for the row:
That's it, basically.