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!
-
I am troubling with listview which should contain Image(on Left side) and Text (On Right Side) but i want to do it programmatically....any help pls – Paresh Mayani Jul 22 '10 at 09:22
3 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.
-
Ya i have already tried it...but i want to Display RSS Feed's Image and text ...is it helpful ? – Paresh Mayani Jul 22 '10 at 10:34
-
-
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) – Paresh Mayani Jul 22 '10 at 10:49
-
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 Jul 22 '10 at 11:01
-
m confused regarding listview with image and text....let me know pls..in lazyloading you have defined items.xml file which contains
and – Paresh Mayani Jul 22 '10 at 11:07, 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 -
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 Jul 22 '10 at 11:26
-
ya I came to know that we can set custom view in ListView by using getView() method...and thanx for providing an example. – Paresh Mayani Jul 22 '10 at 11:52
-
@Fedor.........even this example is the easiest for the beginner: http://www.androidpeople.com/android-custom-listview-tutorial-example/ – Paresh Mayani Jul 22 '10 at 12:37
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.

- 127,700
- 71
- 241
- 295

- 73,164
- 16
- 126
- 119
Hi this class is used to make the image to bind with list view use simple adater and use the following class
class MyViewBinder implements ViewBinder {
public boolean setViewValue(View view, Object data,String textRepresentation) {
if( (view instanceof ImageView) & (data instanceof Bitmap) ) {
ImageView iv = (ImageView) view;
Bitmap bm = (Bitmap) data;
iv.setImageBitmap(bm);
return true;
}
return false;
}
}

- 455
- 6
- 7