In my app I have activity with tabs (let's say 10 tabs). Each tab page contains Fragment with ListView(data displayed in this ListView is loaded dynamically from my server). I use ViewPagerto display these pages. I don't want to keep all the Fragments in memory, so I decided to use FragmentStatePagerAdapter (My adapter class extends these class).
Let's say 3rd tab is selected. Then, when I go for example to the first tab,
Fragmentfor this tab should be created from scratch (that's fine, it's howFragmentStatePagerAdapterworks) but without restoring previous state of this fragment (e.g.,ListViewshouldn't be scrolled to the position saved when thisFragmentwas last accessed - now it is scrolled). So my first question is: how can I achieve such a behaviour? In other words, I want my adapter not to restoreFragmentstate, when it is created from scratch.Once again, let's say 3rd tab is selected. Then, when I go for example to the second tab,
Fragmentfor this tab should be still in memory (that's fine, it's howFragmentStatePagerAdapterworks), but in this situation I want to decide if myListViewdata should be updated (depending on some conditions). How can I notify thisFragmentthat it's selected?