Dynamic change of names ViewPagerIndicator

My current project uses ListFragments to display rows of data. Lines are updated dynamically every few seconds. The number of rows depends on each update and each ListFragment .

I would like to show the row count for the user and think that the ideal place for this would be next to the Fragment heading in the ViewPagerIndicator. I presented a sample image for a better understanding:

Viewpagerindicator

Unfortunately, I don’t quite know how to achieve this. I tried the following:

 public class PagerAdapter extends FragmentPagerAdapter { private int numOne = 0; private int numTwo = 0; // ... @Override public CharSequence getPageTitle(int position) { switch (position) { case 0: return "List 1 (" + numOne + ")"; case 1: return "List 2 (" + numTwo + ")"; default: return ""; } public void setNumOne(int num) { this.numOne = num; } public void setNumTwo(int num) { this.numTwo = num; } } 

When I now call the setNumXXX() method, nothing happens until I go between the fragments, which seems to cause getPageTitle() fire.

My question is: how can I force the header (s) to be updated every time the num value changes?

+4
source share
1 answer

If you call notifyDataSetChanged() on an indicator instance, it will redraw and capture new headers.

+14
source

All Articles