position not retained when coming back from another fragment
See original GitHub issueHi, I use navigation graph in my app and when I leave fragment which contains viewpager and come back (click on “skip” button in attached gif), viewpager’s position is retained, but dots indicator is reset. I know that view is recreated when leaving and coming back, but I noticed ViewPager2.OnPageChangeCallback’s onPageSelected is called with last position, but dots indicator somehow doesn’t react. But when I scroll , indicator jumps to correct position. Please have a look at attached video. Thanks

this is how it’s initialised in onActivityCreated() method:
val pagerAdapter = MyViewPagerAdapter(activity!!)
viewPager.adapter = pagerAdapter
pagerIndicator.setViewPager2(viewPager)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Listview position is incorrectly retain after coming back to ...
when i click on list item a another fragment will load with backstack .Before loading the new fragment i save details about list-view...
Read more >Fragment manager - Android Developers
In other words, the transaction is reversed. If there are no more fragment transactions on the stack, and if you aren't using child...
Read more >how to keep recyclerview scrolled position when i back from ...
Hello, i have gridview when i press item new fragment starts but when i come back the grid is not resumes from the...
Read more >Saving Fragment State Yourself - Medium
Any Fragments that are still in the FragmentManager (either directly visible or still on the back stack) will have their state saved when...
Read more >ViewPager with FragmentPagerAdapter - CodePath Cliffnotes
Usage · Layout ViewPager · Define Fragments · Setup FragmentPagerAdapter · Apply the Adapter · Selecting or Getting the Page · Setup OnPageChangeListener....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@palicka I had the same issue, look my solution, hope it will helps
indicator.setViewPager(pager)pager.post { adapter.notifyDataSetChanged() }Where indicator - is indicator view, pager - is ViewPager, adapter - is PagerAdapter. Indicator internally react on adapter changes, so it will redraw indicators correctly. Hope it helps 😃
Hello, thanks for your contribution ! This issue is now fixed in the new version
4.3Thanks 🔥