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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -