android - savedInstanceState.getParcelableArrayList() return empty list -


If the screen rotates, then I want to save the list of my items, so I applied my object as Done:

Public category video equipment serials qualified, parcelable {

  private string emittal; Private string mvideoID; Private string mThumbUrl; Public video (string title, string id, string thumb url) {this.mTitle = title; This.mvideoID = ID; This.mThumbUrl = thumbUrl; } @ Override Public Int Consultants () {// Tudo Auto-Generated Method Stub Returns 0; } @ Override Public Voice List Topparle (Parcel Dest, Int Flag) {// Todo Auto-Generated Strobe Dist.LiteString (MT); Dest.writeString (mVideoID); Dest.writeString (mThumbUrl); } Public Video (Parcel In) {// TODO Auto-generated Controller Stub mTitle = in.readString (); MVideoID = in.readString (); MThumbUrl = in.readString (); } Public stable final parcelable Manufacturer & lt; Video & gt; Manufacturer = New parcel worthy Manufacturer & lt; Video & gt; () {@ Override public video] Newerre (integer shape) {// Tudo auto-generated method stub new video [size]; } @ Override public video creationFrameParcel (parcel in) {// to-auto object method stub log. A ("Creator", In Reader String ()); Return new video (in); }};  

}

And in the main activity, I've retrieved the saved list of items:

  if (Saved InstantState! = Zero) {ArrayList & lt; Video & gt; Saved = Saved InstantStat.GetRabelableAralyst (Video_LiST); Toast. Make text (this, "Count:" + saved.) (), Toast. LNNGHHORAT). Show (); }  

-> The problem is, the screen list of items is empty after rotating: save.size () = 0 please tell me why? How can I solve it? I

This variable is saved on the InstantState, the CREATE method is right ??

To separate that from the tap, you need to save the object on the Savings InstantState (Bundle Outstate) like this:

  Save InstantState (Bundle) Outstate Protected Zero {outState.putParcelable (VIDEO_LIST, videoList); }  

More info

----------- Update -----------

Android documents say that the onsw insteststate is only called when the app is killed.

This method is said before killing any activity so that when it comes in the future sometime in the future, its position.

Since you are just roaming the screen, the app is not killed, your activity is only resting again, that is why the variable is empty.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -