Home > Mobile >  Android Studio how to realize List<Fragments> The preservation of the? Please answer
Android Studio how to realize List<Fragments> The preservation of the? Please answer

Time:11-15

Android Studio
I have a ArrayList< Fragments could group; Fragment> ArrayList.

When the screen rotation or exit the arrayList to save

I want to save in OnSaveInstanceState parcelable

OutState. PutParcelableArrayList (C_KEY, (ArrayList<? Extends Parcelable>) ArrayList);


But in OnCreate
ArrayList=(ArrayList) SavedInstanceState. GetParcelableArrayList (C_KEY);
Can't use,
Error: Inconvertible types; Always cast a 'Java. Util. ArrayList 'to' Java. Util. ArrayList

If I want to save the entire Fragments could set me to want what?

CodePudding user response:

What is this strange? Why do you want to save the fragments? Save the corresponding data line.
Persistence is the premise of serialization, or implement the Serializable, or implement Parcelable, apparently fragments did not
  • Related