title: How to make two level lists
body: <p>I'm making a simple app where I'll have two level lists. I've created the first level list with <code>ListView</code> but I'm not sure how to go about creating second level list. </p>
  
  <p>Example:</p>
  
  <p>First level list is:</p>
  
  <pre><code> Fruits
   Cookies
  </code></pre>
  
  <p>When Fruits is clicked then the list below is shown:</p>
  
  <pre><code> Bananans
   Grapes
   Apples
  </code></pre>
  
  <p>When cookies is clicked then the list below is shown:</p>
  
  <pre><code> Oreo's 
   Choc Chip
  </code></pre>
  
  <p>Code for first level list:</p>
  
  <pre><code>public class MainActivity extends SherlockActivity {
      SimpleAdapter simpleAdpt;
      List&lt;Map&lt;String, String&gt;&gt; list1 = new ArrayList&lt;Map&lt;String,String&gt;&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          initList();
          ListView lv = (ListView) findViewById(R.id.listView);
          simpleAdpt = new SimpleAdapter(this, list1, android.R.layout.simple_list_item_1, new String[] {"list1"}, new int[] {android.R.id.text1});
          lv.setAdapter(simpleAdpt);
      }
  
      private void initList() {
          // We populate the planets
          list1.add(creatList1("list1", "Fruits"));
          list1.add(creatList1("list1", "Cookies"));
      }
  
      private HashMap&lt;String, String&gt; creatList1(String key, String name) {
          HashMap&lt;String, String&gt; list = new HashMap&lt;String, String&gt;();
          list.put(key, name);
          return list;
      }
  
      /**
       * A placeholder fragment containing a simple view.
       */
      public static class PlaceholderFragment extends Fragment {
  
          public PlaceholderFragment() {
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_main, container, false);
              return rootView;
          }
      }
  
  }
  </code></pre>