如何处理"多达"按钮? [英] How to handle "Up" button?
本文介绍了如何处理"多达"按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何处理向上按钮(SDK版本11+)?我指的是一个在屏幕的顶部,将保存该应用程序图标
How to handle "Up" button (SDK version 11+)? I am referring to the one at the top of screen, that holds the application icon.
在Android的设计文章它被命名为向上按钮,但我没有发现它(或类似)的KeyEvent的领域。
In Android Design articles it was named as "Up button", but I didn't found it (or similar) in KeyEvent fields.
推荐答案
实施 onOptionsItemSelected()
并观看 android.R.id.home
菜单事件,如的文档。
Implement onOptionsItemSelected()
and watch for android.R.id.home
"menu" events, as is described in the documentation.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// do something useful
return(true);
}
return(super.onOptionsItemSelected(item));
}
这篇关于如何处理"多达"按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文