Home > OS >  Hamburger button not opening NavigationUI navigation drawer on Android
Hamburger button not opening NavigationUI navigation drawer on Android

Time:10-30

I am attempting to use enter image description here enter image description here

Note, I am able to open the navigation drawer by swiping from the left side of the screen as expected. That is why navigation drawer is open in second screenshot.

CodePudding user response:

Your problem is with this line:

setContentView(R.layout.activity_category)

What that means is that you are inflating a brand new copy of R.layout.activity_category - you aren't actually using your binding variable at all, which means that the binding.drawerLayout you've set on your AppBarConfiguration isn't actually the DrawerLayout that you've set as your content view.

Instead, you'll want to actually set your binding as the content view of your activity by using the code from the data binding documentation:

setContentView(binding.root)
  • Related