android - NavigationView OnNavigationItemSelectedListener not being called -


i trying use navigationview android support design library in app. reason onnavigationitemselected listener not being called. here code

activity layout

<android.support.design.widget.navigationview     android:id="@+id/navigation_view"     android:layout_width="wrap_content"     android:layout_height="match_parent"     android:layout_gravity="start"     app:headerlayout="@layout/drawer_header"     app:menu="@menu/drawer_menu" />          <framelayout             android:id="@+id/content_frame"             android:layout_width="match_parent"             android:layout_height="match_parent" /> 

activity oncreate()

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(getlayoutid());      toolbar = (toolbar) findviewbyid(r.id.activity_toolbar);     setsupportactionbar(toolbar);     toolbar.inflatemenu(r.menu.common_menu);     final actionbar actionbar = getsupportactionbar();     if (actionbar != null) {         actionbar.sethomeasupindicator(r.drawable.ic_menu_white_24dp);         actionbar.setdisplayhomeasupenabled(true);     }      drawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout);     navigationview = (navigationview) findviewbyid(r.id.navigation_view);     navigationview.setnavigationitemselectedlistener(new navigationview.onnavigationitemselectedlistener() {         @override         public boolean onnavigationitemselected(final menuitem menuitem) {             snackbar.make(contentlayout, menuitem.gettitle() + " pressed", snackbar.length_long).show();             menuitem.setchecked(true);             // allow time after closing drawer before performing real navigation             // user can see happening             drawerlayout.closedrawer(gravitycompat.start);             mdraweractionhandler.postdelayed(new runnable() {                 @override                 public void run() {                     navigate(menuitem.getitemid());                 }             }, drawer_close_delay_ms);             drawerlayout.closedrawers();             return true;         }      });     usernametextview = (textview) findviewbyid(r.id.drawer_header_username);                       usernametextview.settext(getappdcontext().getaccount().getusername());    } 

when make xml, should write down navigationview after baselayout(framelayout, linearlayout, etc..)

<drawerlayout>     <framelayout />     <navigationview /> </drawerlayout> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -