Android fragments fun with ViewPager -
i'm using viewpager in app. there 3 fragments inside pageadapter set in viewpager. works fine , can switch between 3 fragments. have 3 buttons allow me switch between adapters 1 3. problem noticed when click buttons 1 , 3 @ same time. here's happens:
fragment 1 - fragment 3 onattach onviewcreated onresume onpause onattach onviewcreated onresume onpause
as can see above, second fragment never paused , therefore never resumed. both fragments modify same recycler view onresume behaviour above end incorrect state of recycler view.
any thoughts on why might happening , how can fix this?
a viewpager loads (by default) current page, previous page , next page, since have 3 pages second fragment resumed.
the solution set onpagechangelistener , modify recycler view in onpageselected instead in onresume
Comments
Post a Comment