title: Android Listview add item and subitem programmatically
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4587301/android-adding-subitem-to-a-listview">Android - Adding Subitem to a listview</a>  </p>
  </blockquote>
  
  
  
  <p>I have 2 arrays - Namearray &amp; companyarray.
  I want to display it in the listview.
  I have managed to display the names in the list by using the following code:</p>
  
  <pre><code>ArrayAdapter&lt;Comment&gt; adapter = new ArrayAdapter&lt;Comment&gt;(this,
                  android.R.layout.simple_list_item_1, Namearray);
          setListAdapter(adapter);
  </code></pre>
  
  <p>But how do I add a Sub Item to the list as a Company Name.</p>
  
  <p>After following Sai Geetha's blog - I came out with following -
  But the list is appearing empty - it shows 2 black lines with no text on them.
  My Activity background is blue and I have checked in custom_row_view that the textview textcolor is black.
  Have I missed anything?</p>
  
  <pre><code>if(cur!=null &amp;&amp; cur.getCount()&gt;0)
          {
          List&lt;Map&lt;String, String&gt;&gt; data = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
           Log.w("count=","ct="+cur.getCount() );
          for (int i=1;i&lt;=cur.getCount();i++) {
              Map&lt;String, String&gt; datum = new HashMap&lt;String, String&gt;(2);
              Log.w("name=",cur.getString(0) );
              Log.w("compname=",cur.getString(1) );
              datum.put("Name",cur.getString(0));
              datum.put("Company", cur.getString(1));
              data.add(datum);
              cur.moveToNext();
          }
          SimpleAdapter adapter = new SimpleAdapter(this, data,
                                                   R.layout.custom_row_view,
                                                    new String[] {"Name", "Company"},
                                                    new int[] {android.R.id.text1,
                                                               android.R.id.text2});
          setListAdapter(adapter);
          cur.close();
          }
  </code></pre>