Android in TabLayout, ViewPager Fragments not updating consistantly -
i have tablayout , viewpager in android application. when use swipe changing "tab1" "tab2" , use click on "tab1" go first tab fragment inside viewpager not updated.
similar problem exist if use swipe move "tab2" "tab3" , try click on tab move tab2.
otherwise tablayout works fine tabs updated , proper fragments shown if use other combination of swipes or clicks.
//set tabs , viewpager viewpager viewpager = (viewpager) findviewbyid(r.id.mviewpager); viewpager.setadapter(new myfragmentpageadapter(getsupportfragmentmanager(), mainactivity.this)); //layout tablayout tablayout= (tablayout) findviewbyid(r.id.mtabs); tablayout.setupwithviewpager(viewpager);
you should implement setontabselectedlistener
:
tablayout.setontabselectedlistener(new tablayout.ontabselectedlistener() { @override viewpager.setcurrentitem(tab.getposition()); } });
Comments
Post a Comment