views:

202

answers:

2

Hi! 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!

+1  A: 

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.

BrennaSoft
+1  A: 

Here's a complete sample code http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012. You can reuse it.

Fedor
Ya i have already tried it...but i want to Display RSS Feed's Image and text ...is it helpful ?
PM - Paresh Mayani
Of course it is. What exactly problem do you have?
Fedor
Actually i want to set Image and a text whenever i am having a new item in ListView at Run-Time (i.e. total no. of items are not fixed)
PM - Paresh Mayani
That's OK. Adapter can do it. If you have new items in the list you just call adapter.notifyDatasetChanged() and ListView will redisplay all items including the new ones.
Fedor
m confused regarding listview with image and text....let me know pls..in lazyloading you have defined items.xml file which contains <imageview> and <textview> , so how you call this layout for each item in a listview ? for example, i wants to have 10 items such as Name[10], photo[10], now i want to display this data in listview...then what i have to do ?...thanx for such help
PM - Paresh Mayani
Adapter does it all. getView() method in adapter inflates item.xml and displays real data in it. You need to start with some basic ListView tutorial, this one for example http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/.
Fedor
ya I came to know that we can set custom view in ListView by using getView() method...and thanx for providing an example.
PM - Paresh Mayani
@Fedor.........even this example is the easiest for the beginner: http://www.androidpeople.com/android-custom-listview-tutorial-example/
PM - Paresh Mayani