Code example for ListFragment

Methods: getLoaderManager, onActivityCreated, setListAdapter, setListShown

0
        adapter = new ContentAdapter(getActivity());
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setListAdapter(adapter);
        setListShown(false);
        getLoaderManager().initLoader(0, null, this);
    } 
 
    @Override 
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        Uri uri = Uri.parse(getArguments().getString(ARG_URI));
        return new CursorLoader(getActivity(), uri, null, null, null, null);
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
        adapter.swapCursor(cursor);
        setListShown(true);