不调用onSupportNavigateUp()

编程入门 行业动态 更新时间:2024-10-23 19:32:00
本文介绍了不调用onSupportNavigateUp()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发带有ActionBars的应用程序,该应用程序支持Gingerbread及更高版本.所以基本上我正在使用支持库并扩展

I'm developing an app with ActionBars which supports Gingerbread and up. So basically I'm using the support library and extending

ActionBarActivity

ActionBarActivity

我的所有活动.除了

onSupportNavigateUp()

方法.只是没有按照文档中所述调用它.

method. It just does not get called as stated in the documentation.

每当用户选择在其中导航时,都会调用此方法操作栏中显示您应用程序的活动层次结构.

This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.

这很容易,但是我无法弄清楚为什么它不能按预期工作,或者谷歌搜索没有帮助.这是一个错误吗?还是我想念什么?

This is quite easy but I haven't been able to figure out why it does not work as expected nor Googling helped. Is this a bug? or am I missing something?

推荐答案

如果覆盖 onOptionsItemSelected ,则不会调用 onSupportNavigateUp .

if you override onOptionsItemSelected, then onSupportNavigateUp will not be called.

@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // handle ⬅️ button here break; } return true; }

更多推荐

不调用onSupportNavigateUp()

本文发布于:2023-10-28 19:19:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537544.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:onSupportNavigateUp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!