You can add View dynamically in ViewPager inside, but do not know how to dynamically delete View,
at Eap.Workbench.WorkFrambench $ MyViewPagerAdapter.destroyItem (WorkFrambench.java: 347)
Online said notifydatechange, I do not use, but there is no future with the effect<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
ViewPager mTabPager;
mTabPagerAdapter = new TabPagerAdapter ();
mTabPager.setAdapter (mTabPagerAdapter);
When mTabPagerAdapter the data changes, you can call notifydatechange change the display of the content mTabPager. Equivalent to re-run it again mTabPager.setAdapter (mTabPagerAdapter);
Well, you can change the value of a variable mVar to simulate data changes, the following example shows, the variable value is not the same, load two or three pages. But also to try to figure out specifically how their landlord with ah!
private boolean mVar;
private class TabPagerAdapter extends PagerAdapter {
@ Override
public int getCount () {
if (mVar) {
return 2;
} Else {
return 3;
}
}
@ Override
public int getItemPosition (Object object) {
if (! mVar) {
}
}
@ Override
public Object instantiateItem (View container, int position) {
if (mVar) {
} Else {
}
}
}
No comments:
Post a Comment