4

I am building android application where I am using Custom ViewPager. The Problem is explain below in the following steps:

  1. When I open new activity of ViewPager and click on any button and setText any particular value to it. It's working fine.
  2. Problem occurs when I swipe left-right and then click on button to setText on particular TextView; the value gets set as I can toast the value of TextView using getText. But the value does not change in the UI. For exmaple - I swipe any page and now the TextView contains my current position as 2. If I click button and try to do setText(position++) and toast the value, the incremented value is shown in the toast
  3. But still TextView showing 2.

This issue is coming particular in 5.1.1.

Bret
  • 2,283
  • 4
  • 20
  • 28
sofquestion 9
  • 167
  • 4
  • 12
  • It sounds like the TextView is just not getting updated with the new value -- could you post some code for analysis? – Bret Mar 11 '16 at 17:16

1 Answers1

0

I've also been fighting this one for several hours. Best I can determine ViewPager is really designed for a single view where nothing changes after the first time it appears (which hides the bug where SetView stops working). Think of it as showing fixed pages in a book.

If you have an adapter (in my case a CursorAdapter) in the Fragment, you can get it to update using a notifyDataSetChanged() on the adapter after an update is made. This still doesn't fix the setText being ignored after the first time the page is rendered. Another solution may be to use Action Tabs with Activities instead of Fragments, but this has been depreciated. Still looking for a better solution.

Frank
  • 605
  • 1
  • 8
  • 14