我正在开发一个支持 Gingerbread 及更高版本的 ActionBars 应用程序。所以基本上我正在使用支持库并扩展
ActionBarActivity
我所有的 Activity 。一切正常,除了
方法。它只是没有像文档中所述那样被调用。
This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.
这很简单,但我无法弄清楚为什么它不能按预期工作,谷歌搜索也没有帮助。这是一个错误吗?还是我遗漏了什么?
最佳答案
如果您覆盖 onOptionsItemSelected
,则不会调用 onSupportNavigateUp
。
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// handle ⬅️ button here
break;
}
return true;
}
关于android - onSupportNavigateUp() 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18780112/