Android Navigation Drawer Questions!

Asked 2 years ago, Updated 2 years ago, 26 views

I have a question for the navigation drawer!

There are A and B in the navigation drawer menu I want to make sure that menu B is selected when I press the protection button on the screen that comes out when I press menu A. What should I do?

android

2022-09-22 20:24

1 Answers

I think the method will change depending on how you implemented the menu of the navigation drawer. First, when creating a new project in Android Studio, I clicked on "Navigation Drawer Activity" in the project wizard and explained it based on the code created.

You can use the setCheckedItem() function in NagationView to select a specific menu in the navigation drawer.

final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          navigationView.setCheckedItem(R.id.nav_manage);
      }
});


2022-09-22 20:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.