gerdress.blogg.se

Navigation drawer in android studio example java
Navigation drawer in android studio example java






The code inside ‘onNavigationItemSelected’ method is simply displaying a toast message. Then we add a ‘setNavigationItemSelectedListener’ on the ‘nv’ variable, which is the navigation view, to listen for any click events on selecting a particular item from the drawer.

navigation drawer in android studio example java

In lines 14–16 we declare instance variables required for the navigation drawer and we later find them using the findViewById method inside the onCreate() function. For this one, it is highly recommended to learn Java as it is the official Android language.

navigation drawer in android studio example java navigation drawer in android studio example java

Rename the package name to whatever you had chosen in the beginning, you can find the package name in the Manifest.xml file.








Navigation drawer in android studio example java