McBodik
McBodik

Reputation: 753

ViewPager recache pages

When I add page after current page, and flip to it, I see not added page, but cached page.

Is this possible recache pages manually after adding new page if new page is near current page?

P.S. notifyDataSetChanged() in adapter doesn't help.

Upvotes: 0

Views: 30

Answers (1)

MDragon
MDragon

Reputation: 1886

I apologize as I can't comment so this will have to do as an answer:

This will depend on the adapter you wrote or are using, and the exact method. Namely, if you were using a customized adapter with the appropriate overridden methods [which would be best for anything fairly complicated like this]:

  1. When you add the new fragment/page, add it to the internal list within the page [which should work naturally with the other overridden functions, including getCount()]
  2. Make sure to set up the fragment appropriately and implement its lifecycle accordingly so its data changes. [Ie, this is a possible source for your bug if you're using an adapter] If you merely used the onCreate and other basic lifecycle functions, then it may be an issue where the lifecycle method already occurred so the changes won't be taken place [Possible solution: call a function in this case]

That's the basics of the issue. Without any code for the adapter and how+where it's being used, I can't say much else. Hope this helps.

Upvotes: 1

Related Questions