web stats

Android – ListView Image with Text

Android – ListView Image with Text with CustomAdapter (ArrayAdapter)

In this post we are going to learn how to use listview image with text in android.

Firstly we are creating new appliction like this named ListViewImageWithText.

Now we going to activity_main.xml file and add new ListView. Our images and texts will bee shown in here.

Here is our activity_main.xml file code;

Now we need to new layout for listing our data to inside there. I’m going to create new layout named listview.xml. Then add inside this layout imageView and textView.

Here is our listview.xml layout file code;

Then we need images. I have 6 images. barni.jpg, fred.jpg, jerry.jpg, tom.jpg, donald_duc.jpg and tweety.jpg. I’m going to copy these image to drawable folder.

Then we need new ArrayAdapter. I’m creating new class and add these codes in here;

Then go to MainActivity class, add listview property, new String array named cartoonNames and Integer array named imgId. Then set listview with customAdapter.


Now our listview with image application ready. Just run;


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *