Code example for ListFragment

Methods: getActivity, onCreate, setRetainInstance

0
	 
	private CategoriesAdapter mAdapter;
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mAdapter = new CategoriesAdapter(getActivity());
		setRetainInstance(true);
	} 
	 
	@Override 
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setListAdapter(mAdapter);
		getLoaderManager().initLoader(0, null, this);
	} 
 
	@Override 
	public void onListItemClick(ListView l, View v, int position, long id) {
		Intent intent = new Intent(getActivity(), ItemsActivity.class);
		intent.putExtra(C.CID, id);