title: Adding ListView Sub Item Text in Android
body: <p>I have created an RSS reader that lists items in a listview.  I also want a date below each item, but I have no idea how to do that.  I need someone's help to make the Sub Item text display the pubDate that was retrieved from the RSS feed.</p>
  
  <p>This is the code I have for my class:</p>
  
  <pre><code>public class RSSReader extends Activity implements OnItemClickListener
  {
      public final String RSSFEEDOFCHOICE = "http://app.calvaryccm.com/mobile/android/v1/devos";
  
      public final String tag = "RSSReader";
      private RSSFeed feed = null;
  
      /** Called when the activity is first created. */
  
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.main);
  
          // go get our feed!
          feed = getFeed(RSSFEEDOFCHOICE);
  
          // display UI
          UpdateDisplay();
      }
  
      private RSSFeed getFeed(String urlToRssFeed)
      {
          try
          {
              // setup the url
             URL url = new URL(urlToRssFeed);
  
             // create the factory
             SAXParserFactory factory = SAXParserFactory.newInstance();
             // create a parser
             SAXParser parser = factory.newSAXParser();
  
             // create the reader (scanner)
             XMLReader xmlreader = parser.getXMLReader();
             // instantiate our handler
             RSSHandler theRssHandler = new RSSHandler();
             // assign our handler
             xmlreader.setContentHandler(theRssHandler);
             // get our data via the url class
             InputSource is = new InputSource(url.openStream());
             // perform the synchronous parse           
             xmlreader.parse(is);
             // get the results - should be a fully populated RSSFeed instance, or null on error
             return theRssHandler.getFeed();
          }
          catch (Exception ee)
          {
              // if we have a problem, simply return null
              System.out.println(ee.getMessage());
              System.out.println(ee.getStackTrace());
              System.out.println(ee.getCause());
              return null;
          }
      }
      public boolean onCreateOptionsMenu(Menu menu) 
      {
          super.onCreateOptionsMenu(menu);
          menu.add(Menu.NONE, 0, 0, "Refresh");
          Log.i(tag,"onCreateOptionsMenu");
          return true;
      }
  
      public boolean onOptionsItemSelected(MenuItem item){
          switch (item.getItemId()) {
          case 0:
  
              Log.i(tag,"Set RSS Feed");
              return true;
          case 1:
              Log.i(tag,"Refreshing RSS Feed");
              return true;
          }
          return false;
      }
  
      private void UpdateDisplay()
      {
          TextView feedtitle = (TextView) findViewById(R.id.feedtitle);
          TextView feedpubdate = (TextView) findViewById(R.id.feedpubdate);
          ListView itemlist = (ListView) findViewById(R.id.itemlist);
  
  
          if (feed == null)
          {
              feedtitle.setText("No RSS Feed Available");
              return;
          }
  
          if(feedtitle != null)
              feedtitle.setText(feed.getTitle());
          if(feedpubdate != null)
              feedpubdate.setText(feed.getPubDate());
  
  
          ArrayAdapter&lt;RSSItem&gt; adapter = new ArrayAdapter&lt;RSSItem&gt;(this,android.R.layout.simple_list_item_1,feed.getAllItems());
  
          itemlist.setAdapter(adapter);
  
          itemlist.setOnItemClickListener(this);
  
          itemlist.setSelection(0);
      }
  
      @Override
      public void onItemClick(AdapterView parent, View v, int position, long id)
      {
          //Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");       
  
          Intent itemintent = new Intent(this,ShowDescription.class);
  
          Bundle b = new Bundle();
          b.putString("title", feed.getItem(position).getTitle());
          b.putString("description", feed.getItem(position).getDescription());
          b.putString("link", feed.getItem(position).getLink());
          b.putString("pubdate", feed.getItem(position).getPubDate());
  
          itemintent.putExtra("android.intent.extra.INTENT", b);
  
          startActivity(itemintent);
      }
  }
  </code></pre>
  
  <p>This is my XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
   &lt;TextView  
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:text="Android RSSReader"
  android:id="@+id/feedtitle"/&gt;
  &lt;TextView  
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:text=""
  android:id="@+id/feedpubdate"/&gt;
  &lt;ListView
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:id="@+id/itemlist"
  
  android:fastScrollEnabled="true"/&gt;    
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is what it looks like now in Eclipse:</p>
  
  <p><img src="https://i.stack.imgur.com/xLOqZ.png" alt="ListView Currently"></p>
  
  <p>This is what it looks like running:</p>
  
  <p><img src="https://i.stack.imgur.com/aVBqy.png" alt="In Process"></p>
  
  <p>How to make the Sub Item text display the pubDate that was retrieved from the RSS feed?</p>