RSS Reader Android App Tutorial 6: Show Image In Listview

On February 20, 2015, in Android, by James Liu

New Update Version 3.80:

  • Load featured image from RSS Feed
  • Show image in ListView
  • Cache image in local storage
  • Scale image bitmap to fix out of memory issue

In the latest RSS standard, there is no tag for image. So in my previous project, I just preload an Android icon on each ListView row. In the past few weeks, many friends send me messages to request loading image in ListView. But, you need to keep in mind that the image tag is not specified in RSS Standard. In my example, I am using a wordpress plugin JMS Rss Feed in my website, so that RSS of my website will return a <jms-featured-image> tag which will contain a featured image in each article. In my Android RSS Reader App, I will search for tag to get the image url and load it into ListView.

This is the No.6 Android tutorial about how to create a Rss Reader Android App. If you want to build a RSS Reader step by step, you’d better start from the beginning. Here is the full tutorial list for this course.

Add Image Tag In Your Rss

Before you start to build your RSS Reader App, you need to make sure there is image tag in your RSS feed. Since the image tag isn’t included in the RSS standard, you can install my plugin JMS Rss Feed to add an image tag in your RSS feed if you are using WordPress to build your website or blog. After installing the plugin successfully, there will be a< tag <jms-featured-image> appearing in your RSS Feed.

your website rss feed will look like:

	<title>Transparency Concept in PNG</title>
	<pubDate>Sun, 18 Jan 2015 03:11:59 +0000</pubDate>
		<!&#91;CDATA&#91; Other Online Technology &#93;&#93;>
	<guid isPermaLink="false"></guid>
		<!&#91;CDATA&#91;Transparency is fully supported in PNG, but it is very complicated to manipulate in program...&#93;&#93;>
		<!&#91;CDATA&#91;Transparency is fully supported in PNG, but it is very complicated to manipulate in program...&#93;&#93;>

Parse RSS Reed XML And Get Image URL

After we get rss feed ready, we can add some code to get the image url from rss feed. I am using XmlPullParser to parse the XML. So when I get a start tag whose name is “jms-featured-image”, we set the flag to get the image link. Here is the code example:

if (eventType == XmlPullParser.START_TAG) {
	if (xpp.getName().equals("item")) {
		pdData = new PostData();
		currentTag = RSSXMLTag.IGNORETAG;
	} else if (xpp.getName().equals("title")) {
		currentTag = RSSXMLTag.TITLE;
	} else if (xpp.getName().equals("link")) {
		currentTag = RSSXMLTag.LINK;
	} else if (xpp.getName().equals("pubDate")) {
		currentTag = RSSXMLTag.DATE;
	} else if (xpp.getName().equals("jms-featured-image")) {

After we set the flag as RSSXMLTag.FEATURED_IMAGE, we will handle all the incoming text as the image url. Here is the source code:

if (eventType == XmlPullParser.TEXT) {
	String content = xpp.getText();
	content = content.trim();
	if (pdData != null) {
		switch (currentTag) {
		case TITLE:
			//do something...
		case LINK:
			//do something...
		case DATE:
			//do something...
		case CONTENT:
			//do something...
		case GUID:
			//do something...
			if (content.length() != 0) {
				if (pdData.postThumbUrl != null) {
					pdData.postThumbUrl += content;
				} else {
					pdData.postThumbUrl = content;
			//do something...

All above code is modified basing on my third tutorial Parse XML in Android. Now we get all post information from the RSS Feed, including post title, date, description, featured image url and content. In next task, we will show the post featured image in ListView.

Load RSS Image In ListView

In last step, we already get all post information from RSS Feed xml. In this step, we will load image in each row of ListView. We will work in PostItemAdapter class. Once the ListView wants to get a View for its row, we will prepare a View with image and title. First of all, I will add two new attributes in ViewHolder class.

static class ViewHolder {
	TextView postTitleView;
	TextView postDateView;
	ImageView postThumbView;
	String postThumbViewURL;

The postThumbView is the ImageView which will show the post iamge. The postThumbViewURL is the image url where I will load the image in AsyncTask. Here is the example source code of getView in class PostItemAdapter:

public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder viewHolder;
	if (convertView == null) {
		convertView = inflater.inflate(R.layout.postitem, null);

		viewHolder = new ViewHolder();
		viewHolder.postThumbView = (ImageView) convertView.findViewById(;
		viewHolder.postTitleView = (TextView) convertView.findViewById(;
		viewHolder.postDateView = (TextView) convertView.findViewById(;
	} else {
		viewHolder = (ViewHolder) convertView.getTag();

	PostData post = datas.get(position);
	if (post.postThumbUrl != null) {
		viewHolder.postThumbViewURL = post.postThumbUrl;
		new DownloadImageTask().execute(viewHolder);
	} else {

	return convertView;

For DownloadImageTask class, you can refer this article Download Images by AsyncTask. There is a very good example to teach you how to download image by AsyncTask.

More Performance Improvement

Right now, we successfully load the RSS feed image into the ListView. However, there are still much room to improve the performance. One improvement is downloading the images and saving them offline. This cache mechanism will improve the user experience significantly. When caching the image offline, the ListView doesn’t need to download the image again and again when your users are scrolling the ListView up and down. For more information, you can check this article Android Save And Load Downloading File Locally

The second improvement is scale down the image before showing them in ListView. As we just need to show an image icon besides each post in ListView, the image icon size may be 100 x 100 pixels or even smaller. We really don’t need a large image like 300 x 400 pixels or 600 x 300 pixels as our icon. So we can load a lower resolution image in memory and display it in the ListView. This improvement will save huge amount of memory in our app and it will make ListView scrolling more smoothly.

Android Rss Reader 3.8

Android Rss Reader 3.8

Try The Example With All Improvements

You can download and install this android app by click the following link, or scan the following QR code to download and install on your android phone simply. If you feel it is helpful, please support me by clicking the banner inside the app.
Download and Run Rss Reader App on Your Android Phone

Get Full Improvement Source Code Under $9.99

You will get whole Android RSS Feed App source code at $9.99. After you get the source code, you have the full right to use it.

What You Will Get

  • Loading RSS Feed from internet
  • Parse RSS Feed XML
  • Show post title in a list
  • Load post image beside title
  • Cache image offline
  • Scale image small to fit icon size

What You Can Do

  • Load your own website rss feed
  • Monetize with AdMob Ads
  • Use in your own project
  • Publish In Google Play

17 Responses to “RSS Reader Android App Tutorial 6: Show Image In Listview”

  1. Stefan says:

    if i open an item i get the title en description but i dont get the featured image above the title, is it possible? and is it possible to load youtube movies from the feed?

    Greets Stefan

  2. James Liu says:

    Regarding your questions:

    1. It is possible to load featured image above the title.
    2. For youtube movies, I have not tried. You may try it by yourself.

  3. Eric says:

    What if I wanted to produce multiple RSS feeds on multiple tabs which are swipeable?

  4. karthik says:

    will this work offline

  5. prodip says:

    i need to parse multiple website parse and show in one listview with image and sort by date time

  6. Anton says:

    If i want to parse multiple website, should i create new class and new list view ?


    • James Liu says:

      Hi Anton,

      It depends on how you want to show the rss list. If you want to show all rss feed in one list, then, you don’t need to create a new class and a new list. If you want to show news in separate page, then, you can create one.

      But for my option, you’d better to store news data in two dimension array, instead of creating class to do so.

      Best Regards

  7. prodip says:

    i want to buy it (Load RSS Image In ListView), but i have to Paypal , i want to payment you by Neteller or Skrill account.

  8. Mostafa Omar says:

    the code doesn’t work on blogs.
    when I replace the rss url in your code with rss url of my blog and then run the app it shows nothing. any help?

    • James Liu says:

      Hello Mostafa,

      This project is tested many peoples. First, please confirm that the original project working properly. After that, if you change the rss feed, please make sure your rss feed content provides standard rss format.

      If you still have problem, you can provide your rss feed url to us , we can check your rss feed.

Leave a Reply

Premium WordPress Themes

WordPress Themes