Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView with images and text [duplicate]

What's the way to create a listview with images on the left side and text right after it? (Note: the images were previously downloaded from the Net) Thanks in advance!

like image 562
rui pinheiro Avatar asked Apr 05 '10 18:04

rui pinheiro


2 Answers

Here's a complete sample code Lazy load of images in ListView. You can reuse it.

If you have new items in the list you just call adapter.notifyDatasetChanged() and ListView will redisplay all items including the new ones.

The getView() method in adapter inflates item.xml and displays real data in it. You need to start with some basic ListView tutorial, such as the one at Android Series: Custom ListView items and adapters.

like image 107
Fedor Avatar answered Sep 28 '22 05:09

Fedor


A ListView item can have it's own custom layout. When you create your adapter for the ListView you can pass in the layout id to the Adapter constructor. See SimpleAdapter and ArrayAdapter.

=> You will have to extend an Adapter and implement getView() to property set the image+text.

like image 32
Robby Pond Avatar answered Sep 28 '22 05:09

Robby Pond