Activity中的setDefaultKeyMode()
来源:互联网 发布:李聪明 知乎 编辑:程序博客网 时间:2024/06/05 09:29
如果在Activity中的onCreate()方法中使用setDefaultKeyMode()可以做到在当前activity中打开拨号器、执行快捷键、启动本地搜索、启动全局搜索。
这个启动啥,要看setDefaultKeyMode中传了啥参数,不同的参数见下:
/** * Use with {@link #setDefaultKeyMode} to turn off default handling of * keys. * * @see #setDefaultKeyMode */ static public final int DEFAULT_KEYS_DISABLE = 0; //如果设为这个,则在activity中按键的不做响应 /** * Use with {@link #setDefaultKeyMode} to launch the dialer during default * key handling. * * @see #setDefaultKeyMode */ static public final int DEFAULT_KEYS_DIALER = 1; //如果设为这个,则在activity中按键会打开拨号器 /** * Use with {@link #setDefaultKeyMode} to execute a menu shortcut in * default key handling. * * <p>That is, the user does not need to hold down the menu key to execute menu shortcuts. * * @see #setDefaultKeyMode */ static public final int DEFAULT_KEYS_SHORTCUT = 2; //如果设为这个,则在activity中按键会启动快键键 /** * Use with {@link #setDefaultKeyMode} to specify that unhandled keystrokes * will start an application-defined search. (If the application or activity does not * actually define a search, the the keys will be ignored.) * * <p>See {@link android.app.SearchManager android.app.SearchManager} for more details. * * @see #setDefaultKeyMode */ static public final int DEFAULT_KEYS_SEARCH_LOCAL = 3; //如果设为这个,则在activity中按键会打开本地搜索 /** * Use with {@link #setDefaultKeyMode} to specify that unhandled keystrokes * will start a global search (typically web search, but some platforms may define alternate * methods for global search) * * <p>See {@link android.app.SearchManager android.app.SearchManager} for more details. * * @see #setDefaultKeyMode */ static public final int DEFAULT_KEYS_SEARCH_GLOBAL = 4; //如果设为这个,则在activity中按键会打开全局搜索
Select the default key handling for this activity. This controls what will happen to key events that are not otherwise handled(没有操纵的按键,在局部搜索是,我没设置之前,点击数字键是没有反应的,但是我点击以后,数字键就会自动搜索对应的点击的数字按键). The default mode (DEFAULT_KEYS_DISABLE
) will simply drop them on the floor. Other modes allow you to launch the dialer (DEFAULT_KEYS_DIALER
), execute a shortcut in your options menu without requiring the menu key be held down (DEFAULT_KEYS_SHORTCUT
), or launch a search (DEFAULT_KEYS_SEARCH_LOCAL
and DEFAULT_KEYS_SEARCH_GLOBAL
).
Note that the mode selected here does not impact the default handling of system keys(因为起作用的都是以前没有handled的按键,比如数字键之类的。), such as the "back" and "menu" keys, and your activity and its views always get a first chance to receive and handle all application keys.
Parameters
See Also
DEFAULT_KEYS_DISABLE
DEFAULT_KEYS_DIALER
DEFAULT_KEYS_SHORTCUT
DEFAULT_KEYS_SEARCH_LOCAL
DEFAULT_KEYS_SEARCH_GLOBAL
onKeyDown(int, KeyEvent)
- Activity中的setDefaultKeyMode()
- Activity中的setDefaultKeyMode()
- Activity中的setDefaultKeyMode()
- Activity中的setDefaultKeyMode()
- Activity中的setDefaultKeyMode()基本用法
- Activity中的setDefaultKeyMode()基本用法
- 通过setDefaultKeyMode设置Activity的五种按键模式
- setDefaultKeyMode 用法介绍
- setDefaultKeyMode 用法介绍
- setDefaultKeyMode 用法介绍
- setDefaultKeyMode 用法介绍
- android 中的activity介绍
- android中的activity生命周期
- Android中的Activity生命周期
- Activity中的onPause
- Android中的Activity
- Android应用中的Activity
- Activity中的效果--虚化
- 三十三、Java图形化界面设计——布局管理器之null布局(空布局)
- HDU-1548(BFS搜索)
- 安装xampp后apache不能启动解决方法
- java中的URL类的一些测试
- 女人,男人
- Activity中的setDefaultKeyMode()
- 2011-12-01 15:03 JSP和J2EE基础
- 修改版本名称及手机型号
- 说谎者
- Android中数据文件解析(Json解析)
- CX51 用户手册----RET_XSTK伪指令
- 婚姻是什么
- js 倒计时
- subversion配置及权限管理