In BottomAppBar the navigation drawer item click doesn't work

navigation drawer with bottom navigation android example
add item at bottom of navigation drawer
androidx navigation drawer
navigation drawer icon
material navigation drawer android
bottom navigation drawer android
material design navigation bar

I have implemented a BottomAppBar in my app. Following this article Implementing BottomAppBar menu and Navigation drawer Control

Everything works just fine but the problem is that the navigation drawer items doesn't show Toast or anything else. In a word it don't get any click. Here's my source code Github

I also tried Log.d in onNavigationItemSelectedListener but it doesn't also show anything to Logcat.

The NavigationView belongs to BottomNavigationDrawerFragment , You should do below in fragment BottomNavigationDrawerFragment class:

navigationView.setNavigationItemSelectedListener(new OnNavigationItemSelectedListener() {

                    @Override
                    public boolean onNavigationItemSelected(MenuItem menuItem) {

                        switch (menuItem.getItemId()) {
                        case R.id.navigation_item1:
                            ...
                            break;
                        case R.id.navigation_item2:
                            ...
                            break;
                        case R.id.navigation_item3:
                            ...
                            break;
                        default:
                            ...
                            break;
                        return true;
                    }
                });

And you also need get navigationView in fragment.

Edited:

In fragment:

@Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.your_fragment_layout,
                container, false);
        NavigationView  navigationView = (NavigationView )view.findViewById(.....);
        navigationView.setNavigationItemSelectedListener(
        ....
        return view;
    }

Navigation Drawer in bottomappbar android, you should add a drawer icon in your bottomAppbar , then use a bottomsheet for the drawer. for your drawer you have two choices: 1- go with  BottomAppBar menu and Navigation control Now the menu items should be shown within BottomAppBar. Handling Menu Item Click. And for the navigation drawer item clicks you can use the

You can have a look on following example. Hope it will work for you:

Navigation Drawer and BottomBar example

Implementing BottomAppBar II: Menu and Navigation Drawer Control, Now the menu items should be shown within BottomAppBar. Handling Menu Item Click. In order to handle the BottomAppBar menu item clicks  I am making an app from the example of Android Developers with the Navigation Drawer. I made the items but I don't know how I can open new Activity from each of items enlisted. This is the MainAc

Try setting MenuItem ClickListener manually and see if it works for you.

BottomAppBar bar = (BottomAppBar) findViewById(R.id.bar);

bar.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
        // Handle actions based on the menu item
        return true;
    }
});

Fragment Navigation Drawer, Read the material design style navigation drawer document for specs on styling Each item when clicked will switch the relevant fragment into the activity's container view. ActionBarDrawToggle() does not require it // and will not render the  To add a navigation drawer, declare your user interface with a DrawerLayout object as the root view of your layout. Inside the DrawerLayout, add one view that contains the main content for the screen (your primary layout when the drawer is hidden) and another view that contains the contents of the navigation drawer.

Navigation drawer, DoUse a navigation drawer for five or more primary destinations. Bottom navigation drawers are a specialized type of modal drawer for use with a bottom app bar. Each item describes its destination using a text label and optional directly below the drawer's sheet and can be tapped or clicked to dismiss the drawer. and add this code for click item onClick event in navigation drawer does not work. 0. how to call a fragment on menu drawer? 1. can't get a reference to menu item-1.

Update UI components with NavigationUI, If the destination doesn't use a DrawerLayout , the Navigation button is hidden. Note: When using a Toolbar , Navigation automatically handles click As an example, the XML snippets below define a menu item and a The navigation drawer is a UI panel that shows your app's main navigation menu. I have used Navigation Drawer, Bottom Navigation bar and a custom Action bar. Bottom navigation bar and action bar are working fine. navigation drawer also shows menu present under it but the items are not clickable. I have tried all the answers related to . navigation drawer item click not working

ANDROID BOTTOM APP BAR NAVIGATION DRAWER, Furthermore, by selecting items in a drawer, the title of the AppBar component of the drawer, and clicking on a drawer item should update the title in the AppBar. A Place for Navigation Controls Chapter 3 AppBar interaction How to do it getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml.

Comments
  • didn't catch the last thing you said that i also need get navigationView in fragment.
  • NavigationView navigationView = (NavigationView )view.findViewById(.....)
  • @MDFARHAN view is populated in OnCreatedView() method in fragment