java - Multiple Navigation-Drawer Content onclick action -
have basic activity implemented custom toolbar&navigation drawer. had no problem until add buttons on main layout. assigned multiple drawer xml files under menu folder. problem is, when click toolbar hamburger icon, "r.menu.activity_main_drawer1" content coming correctly. when click on button on activity,, other menus comes too. problem starts there. having 2 issues on solutions. toolbar hamburger icon disappearing or menu contents not coming correctly.(when click on button first, "r.menu.activity_main_drawer2" coming right, after closing drawer, if click on toolbar menu, same "r.menu.activity_main_drawer2" appearing again.) hope explain. in advance.
public class index extends appcompatactivity implements view.onclicklistener{ protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.index_p_activity); button 1 = (button) findviewbyid(r.id.finans); one.setonclicklistener(this); button 2 = (button) findviewbyid(r.id.kayit); two.setonclicklistener(this); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new actionbardrawertoggle(index_p.this, drawer, toolbar, "open", "close"); drawer.adddrawerlistener(toggle); toggle.syncstate(); navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view); navigationview.getmenu().clear(); navigationview.inflatemenu(r.menu.activity_main_drawer1); } @override public void onclick(view v) { switch (v.getid()) { case r.id.finans: drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new actionbardrawertoggle(index_p.this, drawer, toolbar, "open", "close"); drawer.adddrawerlistener(toggle); toggle.syncstate(); navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view); navigationview.getmenu().clear(); navigationview.inflatemenu(r.menu.activity_main_drawer2); break; } }
Comments
Post a Comment