Thank you to @Joseinnewworld who just bought 6 of our #NFTs, your appreciation means a lot to us as builders. You are amazing 🤩 #eCash $XEC #nftcollector #NFTDrop #BlockchainSimplicity #NFT #Bitcoin #NFT4season #NFTMint pic.twitter.com/3sWAlhxPpv
— Gaexe (@gaexe_) January 21, 2025
I created a tab view with four tabs and used viewpager in this tab view. In pager view I set recyclerview. I gave five list items to each recycler view initially each recycler view shows 5 items but while swapping back these items become double.
Solution
By default ViewPage can hold 2 fragments and you are using 4 so after switching to 4 if you go back to 1 it will call onCreate of first fragment and vice versa. to prevent this usage.
mViewPager . setOffscreenPageLimit( 4 );
setOffscreenPageLimit will keep all four fragments in the stack and will prevent re-creation.