【问题标题】:return super.onOptionsItemSelected(item); is not calling the parent method返回 super.onOptionsItemSelected(item);没有调用父方法
【发布时间】:2019-11-15 09:08:21
【问题描述】:

我在public boolean onOptionsItemSelected(MenuItem item) {} 中有返回super.onOptionsItemSelected(item); 我想知道是否有任何理由不调用父方法。我不知道您是否需要更多上下文让我知道。

【问题讨论】:

  • 你在onCreate 中添加了这行setHasOptionsMenu(true) 吗?
  • yes 添加到我的活动中但没有取得任何成果
  • 你能发一个minimal reproducible example吗?

标签: java android methods return super


【解决方案1】:

在到达super.onOptionsItemSelected 调用之前,您可能会返回 true(如在许多自定义选项菜单选择处理示例中所发生的那样)。

没有看到你的onOptionsItemSelected 方法和你的onCreate 方法就很难回答

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    • 2012-10-28
    • 2014-08-20
    • 1970-01-01
    相关资源
    最近更新 更多