简体   繁体   中英

Want to add Bottom and Side navigation in one activity but How?

I want to add Bottom navigation and Side navigation drawer in one activity like LinkedIn. I tried to add bottom navigation to the navigation drawer activity but unsuccessful as navigationListener of both can have same names and in one listener how can i separate bottom navigation items and side navigation items.

it doesn't matter if the two listener have the same name, you can add add listener to each one by their full package name.for example you can add listener to Navigation view like this:

navigationView.setNavigationItemSelectedListener(new android.support.design.widget.NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            ///your code here
            return false;
        }
    })

and add listener to Bottom navigation view like this :

bottomNavigationView.setOnNavigationItemSelectedListener(new android.support.design.widget.BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                return false;
            }
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM