Code example for ListFragment

Methods: onCreateViewsetListAdapter, getActivity

0
 
   @Override 
   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
       /** Creating array adapter to set data in listview */ 
       ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity().getBaseContext(), android.R.layout.simple_list_item_multiple_choice, android_versions);
 
       /** Setting the array adapter to the listview */ 
       setListAdapter(adapter);
 
       return super.onCreateView(inflater, container, savedInstanceState);
   } 
 
   @Override 
   public void onStart() { 
       super.onStart(); 
 
       /** Setting the multiselect choice mode for the listview */ 
       getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
   } 
}