Skip to content
Advertisement

onClick method not working in android studio

I made a side navigation drawer and it works fine but whenever I click any option in navigation drawer nothing happens.It’s like it is not taking any input. Onclicking any option I want to redirect user to a new activity but unfortunately it doesn’t happens.

XML code is as follows

JavaScript

Java code is as follows

JavaScript

Advertisement

Answer

I think you need to use the onNavigationItemSelected method when you want to handle click events on the navigation drawer.

Learn more: https://developer.android.com/reference/com/google/android/material/navigation/NavigationView.OnNavigationItemSelectedListener#onNavigationItemSelected(android.view.MenuItem)

Advertisement