【问题标题】:Hide 3-dot menu item when the Navigationbar appears出现导航栏时隐藏三点菜单项
【发布时间】:2016-10-27 17:50:12
【问题描述】:

我想在导航栏出现时隐藏三点菜单项。
我发现了一些不错的主题如何隐藏三点菜单项:
How to disable/hide three-dot indicator(Option menu indicator) on ICS handsets
How do I hide a menu item in the actionbar?
但我找不到我的问题的解决方案。我希望能得到一些帮助。 :)

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.main_menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    infoDialogFragment.aboutMenuItem(this);
    return false;
}

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    actionBarDrawerToggle.syncState();
}


private void setNavigationDrawer() {
    navigationView.setNavigationItemSelectedListener(menuItem -> {


    });
    return false;
}

【问题讨论】:

  • 删除 onCreateOptionsMenuonOptionsItemSelected。设置菜单将消失。
  • 但是当导航栏出现时它应该会消失。

标签: java android xml navigation


【解决方案1】:

从您的活动中删除所有这些代码:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.main_menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    infoDialogFragment.aboutMenuItem(this);
    return false;
}

【讨论】:

    猜你喜欢
    • 2021-10-20
    • 2014-11-08
    • 2019-05-30
    • 2017-02-20
    • 1970-01-01
    • 2018-10-01
    • 2019-05-25
    • 2015-11-04
    • 1970-01-01
    相关资源
    最近更新 更多