Code example for ListFragment

Methods: getActivity, getListView, onStart

0
	private OnElementSelectedListener mListener;
	protected Cursor cursor;
 
	@Override 
	public void onStart() { 
		super.onStart(); 
		getActivity().registerReceiver(loadingDone, new IntentFilter(((MyActivity<?>) getActivity()).getActionComplete()));
		final Object data = getActivity().getLastCustomNonConfigurationInstance();
		if (data == null) {
			cursor = getDataToFillList();
		} else { 
			cursor = (Cursor) data;
		} 
		startManagingCursor(isActivityManagingCursor()); 
		adapter = new SimpleCursorAdapter(getActivity(), getRowResource(), cursor, getFrom(), getTo());
		getListView().setAdapter(adapter);
		getListView().setSelection(cursor.getPosition());
		adapter.setViewBinder(getViewBinder());
		getListView().setOnItemClickListener(getOnItemClickListener());
	} 
 
	@Override 
	public void onStop() { 
		super.onStop(); 
		getActivity().unregisterReceiver(loadingDone);
	} 
 
	private void startManagingCursor(boolean managingCursor) {
		if (managingCursor) {
			getActivity().startManagingCursor(cursor);
		} 
	} 
 
	protected abstract boolean isActivityManagingCursor();