I have a ViewPager backed by a FragmentStatePagerAdapter. The app is a single Activity app, with fragments for each "page". Currently I'm using the ViewPager to display Categories of Products, and each Category will contain a ListView (or RecyclerView) that lists all the products. Once a user taps on a product, the viewpager fragment is replaced by the ProductDetailsFragment. Which is all fine and dandy but when the user presses back, it reloads all the Category fragments. Is there anyway to avoid that? The issue is that if a user had to paginate over 3 pages they'll want to maintain their scroll state.
Asked
Active
Viewed 196 times
0

StackOverflowed
- 5,854
- 9
- 55
- 119
-
You could always just have separate activities for Details as opposed to Categories. – Eligos Apr 24 '15 at 15:00
1 Answers
0
You should use this
fragmentTransaction.add(android.R.id.content, fragment, Fragment.class.getSimpleName());
fragmentTransaction.addToBackStack(Fragment.class.getSimpleName()).commit();

Dmitriy Puchkov
- 1,530
- 17
- 41