android自动弹出软键盘(输入键盘)
来源:互联网 发布:mac自带抠图 编辑:程序博客网 时间:2024/05/21 11:33
很多应用中对于一个界面比如进入搜索界面或者修改信息等等情况,为了用户体验应该自动弹出软键盘而不是让用户主动点击输入框才弹出(因为用户进入该界面必然是为了更改信息)。具体实现这种效果如下:
- EditText editText.setFocusable(true);
- editText.setFocusableInTouchMode(true);
- editText.requestFocus();
- MethodManager inputManager =
- (InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.showSoftInput(editText, 0);
首先要对指定的输入框请求焦点。然后调用输入管理器弹出软键盘。
警告:对于刚跳到一个新的界面就要弹出软键盘的情况上述代码可能由于界面为加载完全而无法弹出软键盘。此时应该适当的延迟弹出软键盘如998毫秒(保证界面的数据加载完成)。实例代码如下:
- Timer timer = new Timer();
- timer.schedule(new TimerTask()
- {
- public void run()
- {
- InputMethodManager inputManager =
- (InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.showSoftInput(editText, 0);
- }
- },
- 998);
0 0
- android自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- Android自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- android editText自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- android 自动弹出软键盘(输入键盘)
- android自动弹出软键盘(输入键盘)
- Android软键盘(三)自动弹出键盘的现象
- android隐藏软键盘 不自动弹出键盘的方法
- Android EditText 自动弹出软键盘,遮挡输入框
- android自动弹出软键盘(输入法)
- android 自动弹出软键盘
- android自动弹出软键盘
- Android自动弹出软键盘
- 实体类中创建数据表中不存在的字段
- mysql登陆问题
- 让PHP7达到最高性能的几个Tips
- 将博客搬至CSDN
- 网址纪录
- android自动弹出软键盘(输入键盘)
- Linux安装keepalived
- EAS BOS Excel导入功能
- CentOS U盘安装
- ios 本地提醒
- Educational Codeforces Round 5 B
- [leetcode] 145. Binary Tree Postorder Traversal 解题报告
- quick-cocos2d-x的热更新机制实现
- CodeForces 471C MUH and House of Cards