Android option menu remove on view pager -


i'm using view pager tabs using toolbar android action bar.

now in 1 of tab ,i'm creating menu fragment ,its working fine set has option menu true on fragment .

question is,how can remove menu when user slides different tab or click on different tab.

what best procedure it.

i'm creating option menu in fragment this

@override     public void oncreate(bundle savedinstancestate) {         // todo auto-generated method stub         super.oncreate(savedinstancestate);          sethasoptionsmenu(true);     }  @override     public void oncreateoptionsmenu(menu menu, menuinflater inflater) {         // todo auto-generated method stub         inflater.inflate(r.menu.custommenu, menu);         super.oncreateoptionsmenu(menu, inflater);     } 

you need have sethasoptionsmenu(true); in fragments

and override below in fragments

@override public void oncreateoptionsmenu(menu menu, menuinflater inflater) {     super.oncreateoptionsmenu(menu, inflater);     menu.clear();    //fragment specific menu creation } 

and need add viewpager listner suggested @madhav


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -