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: enter image description here

and navigationview enter image description here

this how project looks like:

enter image description here

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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -