Reputation: 1181
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
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
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