android - Options menu showing at different fragments(mostly in neighbour Fragment) -
my view pager's adapter like:
public pager(fragmentmanager fm, int tabcount) { super(fm); this.tabcount = tabcount; } @override public fragment getitem(int position) { switch (position) { case 0: return new frag1(); case 1: return new frag2(); case 2: return new frag1(); case 3: return new frag2(); case 4: return new frag1(); default: return null; } } @override public int getcount() { return tabcount; } }
how set tablayout , viewpager in java class:
(int = 0; < 5; i++) { tablayout.addtab(tablayout.newtab()); } pager adapter = new pager(getsupportfragmentmanager(), tablayout.gettabcount()); viewpager.setadapter(adapter); viewpager.beginfakedrag(); viewpager.addonpagechangelistener(new tablayout.tablayoutonpagechangelistener(tablayout));
i getting weird error this:
w/fragmentmanager: movetostate: fragment state frag2{2428405 #1 id=0x7f0c006a} not updated inline; expected state 3 found 2
so how can fix issue? getting answers stack doesn't solve issue, have knowledge this, kindly me!
replace line viewpager.addonpagechangelistener(new tablayout.tablayoutonpagechangelistener(tablayout));
tablayout.settabsfrompageradapter(adapter);
Comments
Post a Comment