如何处理向上按钮(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));
}