Hi folks, I have a navigationGraph inside with Bo...
# android
a
Hi folks, I have a navigationGraph inside with Bottom Navigation and inside one of fragment that attachto bottom navigaiton, i have 4 other fragments with viewpager + tabs and in every fragment i have one recyclerview, everytime i switch the tab and again back to viewpager, as fragment recreated so adapter reset again and scrolling position move to top, how i maintain the state? i done rnd on few things but nothing help kindly is there anyone who can help me to achieve this? Thanks
👀 1
😶 2
u
Are you creating new instance of your fragments inside viewpager adapter? Make viewpager adapter singleton also the fragments inside it.
a
@Umar Ata what do you think single instance always in memory throughout the application ilfecycle?
and i don`t think its best solution??
i
fragment recreated so adapter reset again and scrolling position move to top
If you're saving your state properly, your fragments will be recreated with exactly the same state they had before. That includes the selected tab in a ViewPager and the scroll position in RecyclerViews, etc. It sounds like you need to fix that
✅ 1
a
Thanks @Ian Lake Thats solve my problem.