I\'m using the ViewPager example with ActionBar tabs taken from the Android documentation here.
Unfortunately, as soon as I call the
I fixed it by callinig notifyDataSetChanged() once and just before next call of getCount():
private boolean doNotifyDataSetChangedOnce = false;
@Override
public int getCount() {
if (doNotifyDataSetChangedOnce) {
doNotifyDataSetChangedOnce = false;
notifyDataSetChanged();
}
return actionBar.getTabCount();
}
private void addTab(String text) {
doNotifyDataSetChangedOnce = true;
Tab tab = actionBar.newTab();
tab.setText(text);
tab.setTabListener(this);
actionBar.addTab(tab);
}
private void removeTab(int position) {
doNotifyDataSetChangedOnce = true;
actionBar.removeTabAt(position);
}