Code example for ListFragment

Methods: getActivity, getListView, getResources, onActivityCreated, setListAdapter

0
		getListView().setItemChecked(pos, true);
	} 
 
	@Override 
	public void onActivityCreated(Bundle state) {
		super.onActivityCreated(state);
		DisplayMetrics dm = getResources().getDisplayMetrics();
		REL_SWIPE_MIN_DISTANCE = (int) (120.0f * dm.densityDpi / 160.0f + 0.5);
		REL_SWIPE_MAX_OFF_PATH = (int) (250.0f * dm.densityDpi / 160.0f + 0.5);
		REL_SWIPE_THRESHOLD_VELOCITY = (int) (200.0f * dm.densityDpi / 160.0f + 0.5);
 
		final GestureDetector gestureDetector = new GestureDetector(
				new MyGestureDetector()); 
		View.OnTouchListener gestureListener = new View.OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				return gestureDetector.onTouchEvent(event);
			} 
		}; 
		getListView().setOnTouchListener(gestureListener);
		try { 
 
			elementos = file.leerElementos("recetas.xml", "receta");
			adapter = new ArrayAdapter<String>(getActivity(),
					android.R.layout.simple_list_item_single_choice, elementos);
			setListAdapter(adapter);
			getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
			// getListView().setSelector(android.R.color.darker_gray); 
 
			/* 
			 * if (state != null) { int position = state.getInt(STATE_CHECKED, 
			 * -1);