0

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.

taniya Y
  • 1
  • 2

1 Answers1

0

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;
            }
        });
Farid
  • 1,024
  • 9
  • 16
  • i did as you said but one more problem arose. i copied that code below and " in between " i wrote problem : NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); BottomNavigationView bottomNavigationView=(BottomNavigationView) findViewById(R.id.bottom_nav); bottomNavigationView.setOnNavigationItemSelectedListener("what parameters i pass here?"); – taniya Y May 23 '19 at 06:52
  • As, i'm done with the above problem as, i define the setOnNavigationItemSelectedListener above the bottom navigation declaration but a new problem arose that the onclick of side naviagtion's items are not working why and how to resolve? – taniya Y May 27 '19 at 06:36