Code example for ListFragment

Methods: getActivity, onListItemClick, startActivity

1
	 * @see android.support.v4.app.ListFragment#onListItemClick(android.widget.ListView, android.view.View, int, long) 
	 */ 
	@Override 
	public void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub 
		super.onListItemClick(l, v, position, id);
		/* 
		Fragment newContent = null; 
		switch (position) 
		{ 
		case 0: 
			newContent = new StubContentFragment(); 
			break; 
		case 1: 
			newContent = new MainContentFragment(); 
			break; 
		} 
		if (newContent != null){ 
			switchFragment(newContent); 
		} 
		*/ 
		Intent i = new Intent();
		switch (position){
		case 0: 
			i.setClass(getActivity(), MainActivity.class);
			break; 
		case 1: 
			i.setClass(getActivity(), CurriculumActivity.class);
			break; 
		case 2: 
			i.setClass(getActivity(), ActiActivity.class);
			break; 
		case 3: 
			i.setClass(getActivity(), AgendaActivity.class);
			break; 
		case 4: 
			i.setClass(getActivity(), LibraryActivity.class);
			break; 
		case 5: 
			i.setClass(getActivity(), GPAActivity.class);
			break; 
		case 6: 
			i.setClass(getActivity(), ExerciseActivity.class);
			break; 
		case 7: 
			i.setClass(getActivity(), AcademicActivity.class);
			break; 
		case 8: 
			i.setClass(getActivity(), FreshmanActivity.class);
			break; 
		} 
		if (i != null){
			startActivity(i);
			TryKillMyself(); 
		} 
	} 
	 
	 
	 
	private void TryKillMyself() { 
		/** 
		 * µ÷ÓÃеÄActivityºóɱËÀ×Ô¼º.. 
		 */ 
		if(!DEBUG_DONOT_KILL_ACTIVITY){
			if(getActivity() instanceof BaseFrameActivity){
				BaseFrameActivity baseActivity = (BaseFrameActivity)getActivity();
				baseActivity.KillMyself();
			} 
		} 
	}