Open a new view with NavigationView (android) -
i'm beginner android world. created first project testing, use androidstudio , while creating project decided select , use "navigation drawer activity". default android studio creates relativelayout
called content_main
, when project starts appears in first view. how application looks now:
this how project looks like:
and method switch 1 view other:
public boolean onnavigationitemselected(menuitem item) { drawer.closedrawers(); switch (item.getitemid()){ case r.id.nav_main: setcontentview(r.layout.content_main); return true; case r.id.nav_stickers: setcontentview(r.layout.content_stickers); return true; default: toast.maketext(getapplicationcontext(),"something went wrong",toast.length_short).show(); return true; } }
i when user click on mainview button in navigationview appear mainview (content_main) , if user click on stickersview appear stickerview. don't know how it, searched on net nothing helped me, hope me , let me understand easy thing.
in switch can use fragmentmanager change views. each view should have fragment.
getsupportfragmentmanager().begintransaction() .add(r.id.fragment_container, newfragment).commit();
Comments
Post a Comment