如何处理"多达"按钮?如何处理、按钮、QUOT

2023-09-06 13:25:07 作者:以稀°

如何处理向上按钮(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));
}
 
精彩推荐
图片推荐