@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // BEGIN_INCLUDE(save_instance) // Allow the Controller to save it's instance state so that any checked items are // stored if (mMultiSelectController != null) { mMultiSelectController.saveInstanceState(outState); } // END_INCLUDE(save_instance) }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // The items which will be displayed mItems = Cheeses.asList(); // Set the ListAdapter so that the ListView displays the items setListAdapter( new ArrayAdapter<String>( getActivity(), R.layout.simple_selectable_list_item, android.R.id.text1, mItems)); // BEGIN_INCLUDE(attach_controller) // Attach a MultiSelectionUtil.Controller to the ListView, giving it an instance of // ModalChoiceListener (see below) mMultiSelectController = MultiSelectionUtil.attachMultiSelectionController( getListView(), (ActionBarActivity) getActivity(), new ModalChoiceListener()); // Allow the Controller to restore itself mMultiSelectController.restoreInstanceState(savedInstanceState); // END_INCLUDE(attach_controller) }