dimanche 19 novembre 2017

Save Checkbox states in Fragment

I have a class who extends Listfragmentand implement LoaderManager.LoaderCallbacks<Cursor>so I have my list of country from my database in my ContentProviderall works and I changed juste somme things to have a CheckBox list from android.R.layout.simple_list_item_multiple_choiceso here's my method :

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    l.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    l.setItemChecked(position, true);
    mListener.onPaysSelection(((TextView) v).getText().toString());
}

With private OnFragmentInteractionListener mListener

So I have my checkbox list but when I turn my screen it didn't save the states, I tried with preferences but it's really a mess. In my xml I only have :

    <FrameLayout
    android:id="@+id/liste_fragment"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

nothing more I'm using only my MainActivity et my ListFragment with a CursorLoader. So anyone have the best method to save my boxes states ?




Aucun commentaire:

Enregistrer un commentaire