Code example for ListFragment

Methods: getListViewsetListAdapter, getActivity, onActivityCreated

0
import android.widget.Toast; 
 
public class MenuFragment extends ListFragment {
	Activity activity;
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, new String[] { " Ö÷Ò³"," ½ñÈÕÊ®´ó"," ÂÛ̳°æ¿é",  " ÐÄÇé¶ÌÓï", " Õ¾ÄÚÐÅ", " ֪ͨ", " ÁÄÌì×ßÀÈ", " ÎÒµÄÂí¼×"}));
		getListView().setCacheColorHint(0);
		activity = this.getActivity();
 
	} 
 
	@Override 
	public void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		 NetworkInfo info = ((ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE))
	                .getActiveNetworkInfo();
		 if (info == null || !info.isConnected()) {  
	 	        		Toast.makeText(activity.getApplicationContext(), "ÎÞÍøÂç·ÃÎÊ£¬ÇëÈ·¶¨ÒÑÁ¬½Óµ½ÍøÂ磡",
Contextual code suggestions in your IDE  Get Codota for Java