【问题标题】:When i click drawer navigation menu, sub page button click events not triggering当我单击抽屉导航菜单时,子页面按钮单击事件未触发
【发布时间】:2019-07-25 12:24:52
【问题描述】:

我有抽屉式导航菜单项。当我点击菜单进入活动。但该活动按钮单击事件未触发。没有导航页面按钮点击事件的作品。

带导航页面: LayoutInflater inflater = getLayoutInflater(); LinearLayout container; container = (LinearLayout) findViewById(R.id.content_frame); inflater.inflate(R.layout.activity_main, container);

没有导航页面:

Intent intent1 = new Intent(getApplicationContext(), MainActivity.class);

startActivity(intent1);

没有导航页面工作正常..

它导航到另一个活动。该活动按钮单击事件不会被触发。

【问题讨论】:

  • 你必须把你的问题弄清楚,因为它是不可理解的,
  • 当我单击菜单项时,它导航到子活动。在子活动中有按钮保存、更新等,这些按钮不会触发。这是我的问题。
  • 你能分享子活动xml和按钮点击事件吗?

标签: android android-layout android-activity


【解决方案1】:

如果我正确理解您所说的内容,则单击项目时无法导航。 你有没有重写这个方法:

@Override
    public boolean onNavigationItemSelected(MenuItem item) {

        int id = item.getItemId();
        switch (id){
            case R.id.item1 :
                //Intent for action one
                break;
            case R.id.item2 :
                //intent for action two
                break;
            default:
                return false;
        }
      //if you xant to close the drawer navigation
        this.drawerLayout.closeDrawer(GravityCompat.START);

        return true;
    }

此方法允许您在单击菜单中的项目时执行操作。

【讨论】:

  • No.. 它导航到子活动。但是那个子活动有按钮保存,更新,像这样删除。这个按钮不起作用。
  • 您必须向我们展示活动的代码。我们需要它来帮助您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-02
  • 1970-01-01
  • 2012-03-14
  • 1970-01-01
相关资源
最近更新 更多