简体   繁体   中英

Restoring the Fragment

My application has one activity and 5 fragments. When user clicks on tab "Fragment1", it loads the data from remote place and upload it on ListView. "Fragment2" also doing same job. But when user clicks back on "Fragment1" it again starts loading, instead of loading

How can I restore the fragment from last loaded state?

It might help if you post some code. Meanwhile, my sneaky suspicion is that instead of reusing the same instance, your FragmentPagerAdapter is creating a new instance every time its getItem() is called.

Perform a check in OnStart() of the fragment.

  if(listView has Content || is not null)
      {
              //get the data from remote 
      }
  else
      {
             //don;t do anything
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM