ListView with images and text

How to create a list with images on the left side and text immediately after it? (Note: images were previously downloaded from the network) Thanks in advance!

+6
android listview
source share
3 answers

Here is the complete code example Lazy loading images in a ListView . You can reuse it.

If you have new elements in the list, you simply call adapter.notifyDatasetChanged() and ListView , then you will re-display all elements, including new ones.

The getView() method in the adapter inflates item.xml and displays real data in it. You need to start with a basic ListView tutorial such as Android Series: CustomView Elements and Adapters .

+5
source share

The ListView element may have its own custom layout. When you create your adapter for ListView, you can pass the layout identifier to the Adapter constructor. See SimpleAdapter and ArrayAdapter .

=> You will need to expand the adapter and implement the getView() property to set the image + text.

+1
source share

Hi, this class is used to associate an image with a list view using a 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; } } 
0
source share

All Articles