Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code in the manifest file is wrong. There should be an activity instead of a fragment. That is why you get that CAST exception.</p> <p>Please check out the samples: <a href="http://developer.android.com/resources/samples/Support4Demos/index.html" rel="nofollow">http://developer.android.com/resources/samples/Support4Demos/index.html</a></p> <p>You can download them with the Android SDK Manager.</p> <p>I attach a simple example below:</p> <pre><code>public class FragmentListArraySupport extends FragmentActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the list fragment and add it as our sole content. if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) { final ArrayListFragment list = new ArrayListFragment(); getSupportFragmentManager().beginTransaction().add(android.R.id.content, list).commit(); } } public static class ArrayListFragment extends ListFragment { @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, Shakespeare.TITLES)); } @Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { Log.i("FragmentList", "Item clicked: " + id); } } } </code></pre> <p>and in you manifest file:</p> <pre><code> &lt;activity android:name=".app.FragmentListArraySupport" android:label="@string/fragment_list_array_support"&gt; &lt;/activity&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload