Code example for ListFragment

Methods: getActivity, getLoaderManager, onActivityCreated, setEmptyText, setHasOptionsMenu, setListAdapter, setListShown

        // Task we have running to populate the database. 
        AsyncTask<Void, Void, Void> mPopulatingTask;
        @Override public void onActivityCreated(Bundle savedInstanceState) {
            setEmptyText("No data.  Select 'Populate' to fill with data from Z to A at a rate of 4 per second.");
            // Create an empty adapter we will use to display the loaded data. 
            mAdapter = new SimpleCursorAdapter(getActivity(),
                    android.R.layout.simple_list_item_1, null,
                    new String[] { MainTable.COLUMN_NAME_DATA },
                    new int[] { }, 0);
            // Start out with a progress indicator. 
            // Prepare the loader.  Either re-connect with an existing one, 
            // or start a new one. 
            getLoaderManager().initLoader(0, null, this);
        @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            MenuItem populateItem = menu.add(Menu.NONE, POPULATE_ID, 0, "Populate");
            MenuItemCompat.setShowAsAction(populateItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);