setShortcut
来源:互联网 发布:网络于技术流的意思 编辑:程序博客网 时间:2024/06/08 14:02
http://developer.android.com/reference/android/view/MenuItem.html#setShortcut(char, char)
public abstract MenuItem setShortcut (char numericChar, char alphaChar)
Change both the numeric and alphabetic shortcut associated with this item. Note that the shortcut will be triggered when the key that generates the given character is pressed alone or along with with the alt key. Also note that case is not significant and that alphabetic shortcut characters will be displayed in lower case.
See Menu
for the menu types that support shortcuts.
Parameters
Returns
- This Item so additional setters can be called.
menu.add(0, MENU_ITEM_INSERT, 0, R.string.menu_insert)
.setShortcut('3', 'a')
.setIcon(android.R.drawable.ic_menu_add);
《 转》
在android 的demo里面 有个绘图的程序,按下menu会弹出五个按钮
其设置如下:
menu.add(0, COLOR_MENU_ID, 0, "Color").setShortcut('3', 'c');
menu.add(0, EMBOSS_MENU_ID, 0, "Emboss").setShortcut('4', 's');
menu.add(0, BLUR_MENU_ID, 0, "Blur").setShortcut('5', 'z');
menu.add(0, ERASE_MENU_ID, 0, "Erase").setShortcut('5', 'z');
menu.add(0, SRCATOP_MENU_ID, 0, "SrcATop").setShortcut('5', 'z');
查理相关资料后得出结论:
setShortcut之所以要两个参数来设定两个快捷键是为了应对不同的手机键盘。
数字快捷键为12键键盘(0~9,*,#,共12个按键)所准备的。因为我的键盘不是12键盘,所以数字快捷键是无法工作的。只有字母快捷键能够起效。即当按下menu时候在按下c就能弹出color所对应的对话框了
- setShortcut
- Qt中的setShortcut()函数
- qtp录制一个pop登录的问题
- zoj 2850 Beautiful Meadow
- ini文件操作
- [Cexpert-004] How to output strings to stdout/stderr directly?
- S3C6410_ARM1176 WINCE6.0中增加硬浮点
- setShortcut
- Android界面特效全汇总
- android 项目导入Eclipse各个版本时报Project has no default.properties file! Edit the project properties to set
- POJ 1947 Rebuilding Roads 树形dp
- ViewFlipper 视图切换组件 ViewAnimator
- You have new mail in /var/spool/mail/root 烦不烦你?
- MATLAB中示波器数据的绘图与保存
- ajax跨域访问地本代理的初步研究
- 在函数内定义“局部函数”