search

Home  >  Q&A  >  body text

android - 为什么NavigationDrawer中的Item点击之后一直停留在选中的状态?

高洛峰高洛峰2823 days ago729

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:04:19

    Find the xml file of your menu and change the checkableBehavior of the corresponding group from single to none.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:04:19

    The description of the problem is not clear enough and I don’t know what causes it.
    Solution: Add a click listener for the item and set the item's isChecked to false

    //navigationmenu是一个NavigationView对象
    navigationmenu.getMenu().findItem(R.id.drawer_favourite).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    item.setChecked(false);
                    //do something
                    return false;
                }
            });    

    reply
    0
  • Cancelreply