Rahul Matte
Rahul Matte

Reputation: 1181

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?

Upvotes: 1

Views: 139

Answers (2)

SKK
SKK

Reputation: 5271

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
      }

Upvotes: 0

Franci Penov
Franci Penov

Reputation: 76001

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.

Upvotes: 1

Related Questions