Code example for ListFragment

Methods: getActivity, getArguments, getListView, getLoaderManager, onActivityCreated, setListAdapter

0
    private MahjongPuzzleAdapter mAdapter;
    private Difficulty mDifficulty;
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mDifficulty = Difficulty.valueOf(getArguments().getString("difficulty"));
        getLoaderManager().initLoader(LOADER_PUZZLES, null, this);
        mAdapter = new MahjongPuzzleAdapter(getActivity(), null);
        setListAdapter(mAdapter);
        getListView().setOnItemClickListener(this);
    } 
 
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        return new CursorLoader(getActivity(),
                MahjongContract.Mahjong.CONTENT_URI.buildUpon().appendPath(mDifficulty.name()).build(),
                new String[] {
                        MahjongContract.Mahjong.COL_TITLE, MahjongContract.Mahjong.COL_COMPLETE, MahjongContract.Mahjong._ID 
                }, 
                null, null, null); 
    }