Launching of an active post at NavigationView



  • Assimilation of menu active point NavigationView? Points of the menu FragmentNavigationView located activityNavigationView Initiated himself, not from the standard Google template.



  •     navigation = (NavigationView) findViewById(R.id.navigation_view);
        navigation.getMenu().getItem(0).setChecked(false);
        navigation.setNavigationItemSelectedListener(new navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected(MenuItem menuItem) {
                        int id = menuItem.getItemId();
                        switch (id) {
                            case R.id.navigation_item:
                                if (menuItem.isChecked()) {
                                    menuItem.setChecked(false);
                                } else {
                                    menuItem.setChecked(true);
                                }
                                break; //и т.д.
                    }
        return false;
    

    menu xml:

    <?xml version="1.0" encoding="utf-8"?>
    

    <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="all">
    <item
    android:id="@+id/navigation_item"
    android:checked="false"/>
    ...
    </group>
    ....
    </menu>




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2