Add Android Navigation Drawer Menu Into RSS Reader App

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

New Update Version 4.4:

  • Add Navigation Drawer
  • Load rss from a specified category
  • Enable to switch categories
  • Fix some bugs

In last tutorial, I have talked about how to add featured image in your website rss feed and show image in my Android RSS Reader. To improve the performance in RSS Reader 3.8, I also add a cache mechanism. I am using AsyncTask to download the image from website, then saving it on mini-sd card or external storage. If there is no external storage available, I will save the image in internal storage. Another improvement of Rss Reader 3.8 is scaling down the image bitmap, which will use less memory to hold the post featured image in ListView. Rss Reader 3.8 is a final version which has all the necessary features for a simple RSS Reader. However, there are still mcuh space to improve. For example, we can add a side menu to allow people to switch rss feed from different website, or from different categories. Staring from Android 4, there is a new Android component, Navigation Drawer, to help us implement this type of side menu.

In the new version, I will add navigation drawer in my Rss Reader to allow readers to switch Rss Feed by categories. The new version will be 4.0. From Rss Reader 4.0, the whole project will be built in Android Studio. The reason I am using Android Studio is very simple. Android Studio is the official Android IDE now. Migrating project from Eclipse to Android Studio is a very headache task. After several hours hard working, I gave up in the end. Rss Reader 4.0 is a pure Android Studio project now.

This is the No.7 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.

Build Main App Layout With DrawerLayout

To add a navigation drawer in Rss Reader, we need to use DrawerLayout object as the root view of the layout. In the DrawerLayout, there are two views. One is FrameLayout which holds the main content of our app. The other one is fragment which is the navigation drawer. Here is the example of source code activity_main.xml.

< xmlns:android=""
    xmlns:tools="" android:id="@+id/drawer_layout"
    android:layout_width="match_parent" android:layout_height="match_parent"

    <FrameLayout android:id="@+id/container" android:layout_width="match_parent"

    <fragment android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent"
        android:layout_gravity="start" android:name="com.jmsliu.rssreader.NavigationDrawerFragment"
        tools:layout="@layout/fragment_navigation_drawer" />

Implement Navigation Drawer Fragment

Navigation Drawer is a fragment. Depending on your UI design, you can implement Navigation Drawer in different styles. The most common style of Navigation Drawer is a list.

In Android Studio, it provides a template to create Android App with navigation drawer. If we create the project from the template, we will get a navigation drawer class NavigationDrawerFragment, and a navigation drawer layout xml fragment_navigation_drawer.xml. The navigation drawer layout xml is a simple ListView. Here is the example source code:

<ListView xmlns:android=""
    xmlns:tools="" android:layout_width="match_parent"
    android:layout_height="match_parent" android:choiceMode="singleChoice"
    android:divider="@android:color/transparent" android:dividerHeight="0dp"
    android:background="#cccc" tools:context=".NavigationDrawerFragment" />

In the navigation drawer class NavigationDrawerFragment, we need to instantiate the ListView object with a customized adapter in onCreateView(); Here is the source code example:

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mDrawerListView = (ListView) inflater.inflate(
                R.layout.fragment_navigation_drawer, container, false);
        mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        mDrawerListView.setAdapter(new DrawerListAdapter(
        mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
        return mDrawerListView;

DrawerListAdapter is our customized adapter which will render the category row in the ListView in navigation drawer. If you want to implement a simple side menu with navigation drawer, you can use ArrayAdapter instead.

Handling Click Events in Navigation Drawer

After we successfully initialize the RSS category in navigation drawer, our next job is handling navigation click events. When users select an item in the navigation drawer list, the onItemClick event will be trigger. In above example source code, we set an onItemClick event handler which will call selectItem() when user are clicking on the navigation drawer listview. Here is the source code of selectItem() function.

private void selectItem(int position) {
	mCurrentSelectedPosition = position;
	if (mDrawerListView != null) {
		mDrawerListView.setItemChecked(position, true);
	if (mDrawerLayout != null) {
	if (mCallbacks != null) {

mCallbacks is variable which implements the interface NavigationDrawerCallbacks. In my Android app, it is the main activity. First, let’s see how the NavigationDrawerCallbacks looks like:

public static interface NavigationDrawerCallbacks {
	void onNavigationDrawerItemSelected(int position);

In my main activity, I will implement the interface function onNavigationDrawerItemSelected. Here is the source code.

public void onNavigationDrawerItemSelected(int position) {
	PostListFragment postListFragment = (PostListFragment) getSupportFragmentManager().findFragmentByTag("postlist_fragment");

	DrawerData data = GlobalClass.instance().categoryList.get(position);
	if( != "") {
		String url = String.format(GlobalClass.instance().CATEGORY_RSSURL,;
		postListFragment.rssURL = String.format(GlobalClass.instance().CATEGORY_RSSURL,;
		//Toast.makeText(this, url, Toast.LENGTH_SHORT).show();
	} else {
		postListFragment.rssURL = GlobalClass.instance().RSSURL;
		//Toast.makeText(this, GlobalClass.instance().RSSURL, Toast.LENGTH_SHORT).show();


In the above source code, I will find postlist fragment first. It is a fragment which contains the list of post in a ListView. Basing on the position where users click in the navigation drawer listview, I will refresh the ListView in post list fragment. Here is how the navigation drawer looks like in new RSS Reader.


Different from Rss Reader 3.8, I redesign the RSS Reader 4.0 with MVC model. MainActivity in Rss Reader 4.0 doesn’t handle the post list rendering and XML parser. It will only hold two view, the navigation drawer and the post list fragment. The post list fragment will handle all the rendering jobs for RSS post list. And there is a PostDataModel which will handle all xml parsing jobs.

Try Example Android App

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 $12.99

You will get whole Android Rss Feed App 4.0 source code at $12.99. With this source code, you will get following features:

  • Loading RSS Feed from internet
  • Parse RSS Feed XML
  • Show post title in a list
  • Load post featured image
  • Change categories in navigation drawer
  • Cache image offline

What You Can Do

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

125 Responses to “Add Android Navigation Drawer Menu Into RSS Reader App”

  1. Paul says:

    Hi James, I installed the example RSS reader app on Galaxy S4 (4.4.2) and it ran fine. Then I purchased the source code, and received “Android Rss Reader Example Source Code V4.1” (not 4.4?) on 3/6, built it in Android Studio 1.1.0 and ran it in emulator and S4. In both cases, it crashed with the ‘Unfortunately, JMSLIU RSS has stopped’ error message immediately after clicking on one of the navigation drawer items. I have not been able to find the root cause (no stack trace at all). Is the download source code up to date with bug fixes? Thanks Paul

  2. C.D. says:

    Hi James, I have buy the old Android Rss Reader Example Source Code 2.4, can I receive the new version or at least the 2.4 ?

    Sorry for my english, the email I’ve used for the payment is the same I have left in the comment.

  3. C.D. says:

    Sorry for double post, for new version i mean 2.92 .

  4. KJ says:

    Hi James, can you show how to do if we want to share title of the post using share action provider?

  5. DH says:

    Hi James, I need source code Rss Reader Android App. Help me soon!

    • James says:

      In the middle of the article, there is a title “Get Full Improvement Source Code“, you can get the source code as you follow the instruction.

  6. Malyar says:

    Hello James, I just bought your source code and after paying i was told to download this file called “Android”. I dont know what it is but doesnt seem like the source code to me. Help would me appreciated, thank you.

    • James says:

      Hello, don’t worry about it. If you didn’t get the source code, I will send it to your email. As I tested my payment gateway, it seems to be working properly for me. Any way, just give me several minutes, let me send the source code to your email.

      • Malyar says:

        Ok great thank you, I will be waiting. 🙂

        • James says:

          Sent 🙂

          • Malyar says:

            I got it thank you so much, now I can maybe progress in my school project which is to make an app that reads articles from major news websites. I have one built but its in json and just having huge problems. Anyways thanks alot and keep up the good work, you are helping many people.

  7. KJ says:

    Hi James,
    How can i get the full source code but without the Navigation Drawer Menu? Thanks

  8. Malyar says:

    Hey again, I am having a hard time inserting a rss feed, some reason the category name gets appended to my url. I cant find the code where you append the the category name to the end of the url.

  9. Nabeel says:

    I buy your code but I want to add multiple RSS of different websites can it’s possible?

    • James says:

      Yes. As you get the source code, you can easily to change it to support multiple RSS.

      • Nabeel says:

        in which file I add RSS links? I am totally confused where I add links for example I want to add guardian rss feed where I add this link?

  10. Nabeel says:

    when I add guardian rss it’s show blank screen public static final String RSSURL =””;
    I change this to this but it’s not work public static final String RSSURL =””;

  11. Adalberto says:

    Hello James !
    I would like to know if your app can load images in list from this RSS feeds:

    WordPress (
    Prestashop (
    Feedburner (
    Feed from SSL Websites (

    Can you please test thise links ??
    Will be greate If you can send me an image.

    Tahnks ahead of time

    • James Liu says:

      Hi Adalberto,

      My tutorial shows you how to load standard rss feed from website. You can follow the tutorial and try if the tutorial could work with your rss feed.


  12. Stefan says:

    if i open an item, i get the title en description but i don’t get the featured image above the title, is it possible?


  13. Hydrarian says:

    Hi, I have just purchased your source code but I don’t understand how to implement two things:

    1) How can I show the selected news in a new fragment (in the source code there is a webview that shows home page);

    2) Why when I click on the drawer menu after I clicked on a menu item it doesn’t happen anything? I should select more than once what listview I want to view!

    Thanks in advance

    • James Liu says:


      Regarding your question, the answers are:

      1) In the source code version 4.0 and later, there is a webview, which shows the content of the news, not the home page.

      You will find following code:

      webView.loadData(s, “text/html; charset=utf-8”, “utf-8”);

      2) In drawer menu, which item do you click on? There are 5 menu items, All, Android, IOS, HTMl5, and Other. When you click any of them, it will refresh the list to show you the relevant news list.


      • Hydrarian says:

        Thank you for answering

        1) I know but in my case it shows me only the title of the post without content and below that the whole homepage. Maybe I have to modify the SINGLE_POSTURL? Or what?

        2) Yes, when I only click on the menu it works. But for example if I open an article in a webview and I want to open menu and click on another category, the menu doesn’t work. It opens itself and if I click on a category nothing happends.

  14. laurence_chen says:

    Hi JMS

    I order this App last Friday and I modified it as my application fine. I have two question to that.

    1.How to load cached file (content and image) to webview if internet connection is disabled (off line)when starts this app?
    I need it as a off line reader.

    Currently app cannot load anything if internet was disconnect when starts

    2.If in the postitem view, to disable internet, then click item, the app will crash , are you have good idea to detect internet status in every user’s use condition?



    webView.getSettings().setAppCacheMaxSize(1024 * 1024 * 8);

    • James Liu says:

      That’s a good question. Actually, I am planning to add “push notificatin” and local cache with sqlite in the app. But I was too busy these days. So regarding your questions, you can use sqlite database to save your cache.

      When the internet is disable, I think there will be some exception when you click the postitem view. You can catch the exception and write some code to solve your problem.

      I hope above tips may be helpful.

  15. laurence_chen says:

    thanks , Thanks for your suggestion.

    1.can we access cached data (content or image) replace of sqllite database and put them into postview directly if network was disable?

    Sorry i did don’t understand webview class so much, can we cheat it to access cached data if network is unavailable?

    2.I got your point , maybe you can fix this crash bug if you have free time.


    • James Liu says:

      1. You can use the cached data or sqlite data and put them into postview directly.

      For webview, I know you can put text from cached data, but I am not sure if you can use local cached image in webview.

      • laurence_chen says:

        Hi James,
        Sorry I made some mistaken so as that I get crash status. I need to check side by side what happen and use original source code , but I forget to backup , Can you send the original file to me again ? please mail to my email /

        Do you need any order evidence ? I can provide it


  16. laurence_chen says:

    Hi James,
    sorry to bother you , I solve crash question already.
    my last question is that , i study how to load cache data into postlistfragment & postviewgragment directly when starts APP in off line but got no idea in these days, can you teach me how to insert code in postlistgragment class?


    • James Liu says:

      OK. First, you need to cache your data which is loaded from the server. Let’s say save all text data into sqlite and save image on sd card.

      Then, in the postlistfragment, you can load cached data from sqlite before trying to load data from internet.

      You can use the same idea to load data to postviewfragment.

  17. Corinne says:

    Hi James,

    how can I display only the body of the post and not the entire page when I click on it? Which part of code should I modify? I tried to take it from the rss feed but when I make Log.d(“MyApp”, “RSSCONTENTTAG: ” + currentTag); it appears “CONTENT”. Where else should I modify the code?


    • James Liu says:

      In this source code, the app only loads the content, not the entire page. I don’t really understand your question clearly. Maybe you can prepare some screenshot and show me what you want to implement.


      • Corinne says:

        I want to show only the post text and nothing else. No header, no footer, no css… Like the third image:
        Instead, when I retrieve the post list and I click on one of them to open it, it loads the post page.

        For example I have this rss page:

        And this is what I obtain clicking one of the news (the title plus the entire page!)

        • James Liu says:

          First, do you own the website? If not, it will be very hard for you to only show the body of post. But it is still possible. If the website belongs to you, then you need to make some customization on your website rss feed xml to provide the article body content.

          If the website belongs to you and the website is powered by WordPress, you can use this plugin: JMS Rss Feed Featured Image Plugin. It will solve your problem.

          • Corinne says:

            Yes, that’s my site. I’ve installed the plugin but now it shows me only the title and gives me this in logcat when I open a post:

            “Uncaught ReferenceError: hljs is not defined”, source: data:text/html; charset=utf-8,JMSLIU.COMRiserva di Punta Aderci distrutta da un incendiohljs.initHighlightingOnLoad(); (1)

          • Corinne says:

            I’ve noticed that the variable content is empty in JmsliuStyle file. This happens if I change this:

            public static final String RSSURL = “”;
            public static final String CATEGORY_RSSURL = “”;
            public static final String SINGLE_POSTURL = “”;

            to this:

            public static final String RSSURL = “”;
            public static final String CATEGORY_RSSURL = “”;
            public static final String SINGLE_POSTURL = “”;

        • James Liu says:

          Hi, Corinne

          Your problem about “Uncaught ReferenceError: hljs is not defined” is addressed in

          Please edit this file and delete follow line:

  18. Kleya75 says:


    How can I activate the navigation drawer items even if I have opened a post? They seem not to work when I’m on a post.

    • James Liu says:

      That’s easy. Press back button and you will find the news list already updated. Actually, I think it is necessary to go back automatically from single post view when you click navigation drawer.

      You can check this method:

  19. Lily says:

    Hey, I just purchased the code, but it hasn’t gotten sent, nor did I get a link. I’d really appreciate it if you would send it to me at your earliest opportunity. Thank you.

  20. Attila says:

    unable to pay. eror code:10486.

    Please help.

  21. Carol says:

    I was wondering: how can I add a share button bar below the post in the post fragment in order to share the content of the post on social network?

    • James Liu says:

      Hi Carol,

      That’s easy. First, you already get the article link in the post fragment. Then, you can add a share button under webview. When user clicks the button, you can share the url with facebook sdk.

  22. Nathan says:

    I brought your code. I have modified below code. but in Single_PostURL is not working and I owned the site.
    When I clicked one news from home page, I got with capital letter instead of .
    public static final String RSSURL = “”;
    public static final String CATEGORY_RSSURL = “”;
    public static final String SINGLE_POSTURL = “”;

  23. Ulag says:


    I have purchased your code on June 30 thru my PayPal account.For me Single post URL is not working.when I click any news,it’s displaying Details with capital letter instead of details.

    I have modified below code

    public static final String RSSURL = “”;
    public static final String CATEGORY_RSSURL = “”;
    public static final String SINGLE_POSTURL = “”;

    to this:

    public static final String RSSURL = “”;
    public static final String CATEGORY_RSSURL = “”;
    public static final String SINGLE_POSTURL = “”;

  24. Attila says:

    Hi James,

    finaly i received the payed program.

    Thank you for your effort!


  25. Juan says:

    Hello James,
    Last 23-August I bought your code. The webserver send an error at the moment of the download and the app can not be downloaded.
    Immediatly I send you an email to your paypal email account.
    I think you are on holidays, travelling or something typical of August because I dont have response.

    Please, send me the app at this email account or to the used at paypal transactions when you have a moment.

    23 ago 2015 20:56:02 CEST
    Id. de transacción: 7ST74304R57956419


    • James Liu says:

      Hi Juan,

      I am sorry for the late reply. I have sent you the source code to your email address h******

      • Juan says:

        Hey James dont worry about the late reply. We live in a world where we want and we get everything “now .. now .. now”. If you send me the code via air mail, I will take this few days 😉

        In a few days I will be playing with it. Any question I will ask here, but now I have one question without testing your code.
        What about html tags? I have a feed from joomla that sends a lot of codes and in other rss readers the appear.


  26. Jake Crystal says:

    Hi James,

    I paid for the rss source but the server had errors. Can you send me the source?

    This is the information from PayPal
    Aug 31, 2015 17:35:24 PDT
    Transaction ID: 0KK74294LX965044V

  27. Jake Crystal says:

    Hello James,
    I bought your code yesterday (Aug 31). The web-server had an error when I clicked download project.
    I sent you an email to your Gmail given by Paypal.

    Please, send me the app at this email account or to the used at Paypal transactions when you have a moment.

    Aug 31, 2015 17:35:24 PDT
    Transaction ID: 0KK74294LX965044V

  28. AY says:

    Hi james,
    i just buy your full code RSS and i would like to help for something .

    For example you select “android” via menu drawer and you select an article to read .
    after that you would like to change from “android” to “ios” via menu drawer , and when you press in “ios” , the app do nothing and screen still display the first article you read in “android” category.

    • James Liu says:


      After you select one article to read, you need to go back to the list and select the category. I think it can be improved. For example, you can programmely go back to article list, then refresh the category.

  29. Saher says:

    Hey, I purchased your complete application for development purposes! but I can’t download the app, I get INVALID REQUEST each time!!!!!

    • James Liu says:


      By default, you can download the source code directly after you make the payment. I guess my website is too busy and all resource is exhausted.

      Don’t worry about it. I already sent the source code to your email as an attachment.

      Best Regards

      • Saher says:

        I got it!
        Thanks a lot

        I really appreciate it.

      • Saher says:

        What if I want to load public news site (CNN, Yahoo, etc) RSS feeds to the app as well, how would I do that?
        I’m not sure I fully understand how the works, because it seems to be more customized to your website rss?
        Any suggestions!
        Thanks in advance,

        • James Liu says:

          My rss reader is designed for wordpress website, with my rss plugin. If you want to load the rss from CNN or Yahoo, you have to change some code, like disabling the image.

  30. Amuthan says:


    Is it compatible with blogger feed ?

    Can you implement search function ?

  31. Juergen says:

    Hi, James.
    I bought the source code about paypal and received a file named android to download during the checkout process. I’m sorry not to know what to do with.this downloaded file. I can’t open this.
    Please come back with solving information. Thanks in advance.

    • James Liu says:

      Don’t worry about it. Usually you will see a download link after you make the payment successfully. Anyway, I send the source code to your email which you are using to make the payment.

  32. Juergen says:

    Hi James,
    Its’me again. All works finw under API 21. What is the issue to run this under API 23?

  33. Guillaume says:

    hi james,

    I buy the source code with paypal and I received was very good work. I want to change it because I want the navigation drawer the “android” send to a business, how can I do ?? does it change in ?? I do not see what code to …

    is what to change in it:

    instance.categoryList.add (data);
                 data = new DrawerData ();
                 data.title = “ALL”;
        = “”;
                 data.type = 0;
                 instance.categoryList.add (data);
                 data = new DrawerData ();
                 data.title = “android”;
        = “android”;
                 data.type = 0;

    I am sorry for my bad English, I’m French.

    I thank you in advance,

    • Guillaume says:

      sorry I meant:

      I want to change it because i want the drawer navigation the “android” send to a Activity

      My translator mistranslated

      • James Liu says:

        Do you mean you want to switch to a new Activity once you click the “android” in navigation drawer?

        • Guillaume says:

          hi james,

          yes it is exactly that I would like that when you click on “Android” in the navigation drawer we can open a new activity

          Thank you for your help

          • James Liu says:

            Intent intent = new Intent(this, DisplayMessageActivity.class);
            //send some data to next activity
            //intent.putExtra(EXTRA_MESSAGE, message);

          • Guillaume says:

            ok thank you james, it’s cool.

            However, I do not know where to paste the code, can you tell me ?? and I shall place or the name of the activity that I want to bring up ??

          • James Liu says:

            Hello Guillaume,

            The source code is helping you to understand the tutorial deeply. If you want to customize the project for your own purpose, you’d better read the source code and study. I only provide support if the original source code doesn’t work.


          • Guillaume says:

            OK, thanks anyway

    • James Liu says:

      Just change the “android” to be “business”

  34. Bayo says:

    please I make pay but it showing me failed. please check and get back to me

  35. Bayo says:

    And I hope you have update the SQLite for the offline article.

  36. Bayo says:


    when you are free let me know please

  37. anee says:

    hi james ,

    awaiting for your code .
    already paid .

    • James Liu says:

      Hello Anee,

      After you make the payment, a download windows will appear. Then you can click to download. If you are missing the download link, let me send the source code to your email.


  38. Bayo says:

    Hi james

    I paid for you code and I downloaded it and it work.

    please I have two issue.

    I discover that I can read offline.

    I use BlogSpot for my blog and I can I adjust the code for use.

  39. Hi james

    I paid for you code and I downloaded it and it work.

    I want to parse rss feed in the below link:
    and image is not shown fo all list items why?

  40. Mujib says:

    I have bought recently your code. The RSSURL is ok …. it works but single posturl what I should put in this string in the globalclass.

    when I click one of the items on the list then it should open me the contents regarding the title but it’s not opening the contents it shows only the title

  41. mujib says:

    I am still waiting for your answer. in addition, it loads very slowly even using your url

    • James Liu says:

      Very simple. Please compare my rss xml with your rss xml, you will find out the difference. Loading slow could be the internet issue, not the app problem.

  42. Mike H says:

    James , i sent the Paypal. please send code.

    • James Liu says:

      Oh, actually you could be able to download the source code once you make the payment immediately. But don’t worry, let me send the source code to your email which you are using in PayPal.

Leave a Reply

Free WordPress Themes

WordPress Themes