Code example for ListFragment

Methods: onAttach

0
  } 
 
  private OnMenuClickListener listener;
 
  @Override public void onAttach(Activity activity) {
    super.onAttach(activity);
    listener = (OnMenuClickListener) activity;
  } 
 
  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 
    final int entryCount = 6;
    String[] entries = new String[entryCount];
    for (int i = 0; i < entryCount; i++) {
      entries[i] = "Entry #" + i;
    } 
 
    setListAdapter(
        new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, entries));
  }