title: How to use OnListItemClick action to open a new ListFragment?
body: <p>I have the following ListItem listener, which I want when I click in one of the list open up another list with different options.</p>
  
  <pre><code>public class MyList extends ListFragment {
  
      ...
  
      public void onListItemClick(ListView l, View v, int position, long id) {
          super.onListItemClick(l, v, position, id);
          switch (position) {
          case 0:
              Intent newActivity = new Intent(v.getContext(), AnotherList.class);
              startActivity(newActivity);
          }
      }
  }
  </code></pre>
  
  <p>And this is the other List I want it to open up when I picked the first option</p>
  
  <pre><code>public class AnotherList extends ListFragment {
  
      ArrayList&lt;String&gt; storage = new ArrayList&lt;String&gt;(
              Arrays.asList("Test", "Test"));
      ArrayAdapter&lt;String&gt; adapter;
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          adapter = new ArrayAdapter&lt;String&gt;(getActivity(),
                  android.R.layout.simple_list_item_1, storage);
  
          setListAdapter(adapter);
  
      }
  }
  </code></pre>
  
  <p>I get the following error message though</p>
  
  <blockquote>
    <p>06-02 11:52:39.251: E/AndroidRuntime(1231):
    android.content.ActivityNotFoundException: Unable to find explicit
    activity class {.....}; have you declared this activity in your
    AndroidManifest.xml?</p>
  </blockquote>
  
  <p>Do I have declare <code>AnotherList</code> in my manifest file? Weird if I have to since I did not do that with my first ListFragment.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>FragmentTransaction ft = getFragmentManager().beginTransaction();
  ft.replace(R.id.list_fragment, new AnotherList());
  ft.commit();
  </code></pre>
  
  <p><strong>OLD main_activity.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/LinearLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".MainActivity" &gt;
  
      &lt;fragment
          android:id="@+id/list_fragment"
          android:name="com.sanguosha.MyList"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>NEW working main_activity.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/LinearLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".MainActivity" &gt;
  
      &lt;LinearLayout
          android:id="@+id/list_fragment"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;&lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>