不调用onSupportNavigateUp() [英] onSupportNavigateUp() not called

查看:134
本文介绍了不调用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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆