android软键盘的一些控制
来源:互联网 发布:java三大框架教学视频 编辑:程序博客网 时间:2024/04/27 10:38
"EditText + Button" 形成一个 "输入+按键响应" 的案例在android编程中是最常见不过的了。
但还有一些细节需要注意:
- 在EditText输入后,点击Button进行请求,软键盘应该自行消失
- 在EditText输入后,不点击Button进行请求,而是直接点击软键盘上的"回车",那么也应该能够正常响应请求
针对问题1,可以在响应Button的onClick事件中,主动将软键盘隐藏,加入如下代码即可
- InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
- public void setOnEditorActionListener (TextView.OnEditorActionListener l)
- Set a special listener to be called when an action is performed on the text view. This will be called when the enter key is pressed, or when an action supplied to the IME is selected by the user. Setting this means that the normal hard key event will not insert a newline into the text view, even if it is multi-line; holding down the ALT modifier will, however, allow the user to insert a newline character.
- mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v,int actionId, KeyEvent event) {
- //TODO 这里做"回车"响应处理
- return true;
- }
- });
- android软键盘的一些控制
- android软键盘的一些控制
- android软键盘的一些控制
- Android软键盘的一些控制
- android软键盘的一些控制
- Android软键盘的一些控制
- android软键盘的一些控制
- android软键盘的一些控制
- android软键盘的一些控制
- Android软键盘的一些控制
- android软键盘的一些控制
- android软键盘的一些控制
- android软键盘的一些控制
- Android 软键盘--的控制
- Android软键盘的控制以及更改软键盘
- android 软键盘控制
- Android 控制软键盘
- I android : nputMethodManager 软键盘的 控制
- LPTSTR、LPCSTR、LPCTSTR、LPSTR的意义
- 批处理文件
- 利用opencv提取Hu不变量特征 形状匹配
- 设计模式利剑23--桥梁模式
- Delphi的消息机制探索-第一部分:流程概述(转)
- android软键盘的一些控制
- 逻辑地址、线性地址、物理地址和虚拟地址
- 设计模式利剑22--享元模式
- 此页的状态信息无效,可能已损坏。
- qt学习笔记(五) QGraphicsPixmapItem与QGraphicsScene的编程实例 图标拖动渐变效果
- Linux ———shell简介
- 1A.1 我的2011吹响号角
- 计划任务 crontab 基本运用
- Windows Phone开发之Image控件