android 点击EditText始终不弹出软件键盘实现代码
作者:android_ls 时间:2022-05-23 06:37:19
android 点击EditText始终不弹出软件键盘
场景描述:正常情况下,当点击EditText时,软键盘会弹出来。现在的要求是当点击EditText时,弹日期选择对话框,选择的结果显示在EditText上。若不处理,当点击EditText时,软键盘和对话框都会弹出,显然用户会感觉到不爽。
解决办法,当点击EditText时:
1、存储当前的输入类型
2、设置输入类型为InputType.TYPE_NULL,禁止手机软键盘
3、还原原来的输入类型,因为这次操作完,还要允许用户修改。
4、弹出日期选择对话框,操作完后将结果显示到EditText上。
隐藏软件盘,代码如下:
EditText et_start_time = (EditText) this.findViewById(R.id.et_start_time);
int inType = et_start_time.getInputType();
et_start_time.setInputType(InputType.TYPE_NULL);
et_start_time.onTouchEvent(event);
et_start_time.setInputType(inType);
et_start_time.setSelection(et_start_time.getText().length());
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
来源:http://blog.csdn.net/android_ls/article/details/8642751
标签:android,EditText
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java实现简单树结构
2023-08-06 18:59:12
C#实现记事本查找与替换功能
2022-03-24 00:20:58
![](https://img.aspxhome.com/file/2023/0/84410_0s.png)
springboot自定义stater启动流程
2023-06-07 06:33:45
![](https://img.aspxhome.com/file/2023/5/65165_0s.png)
C#生成随机数功能示例
2022-03-25 04:52:40
![](https://img.aspxhome.com/file/2023/9/92859_0s.png)
C# WinForm-Timer控件的使用
2023-11-20 06:54:00
![](https://img.aspxhome.com/file/2023/7/92837_0s.png)
C#/VB.NET 实现彩色PDF转为灰度PDF
2021-07-23 08:23:49
![](https://img.aspxhome.com/file/2023/9/92889_0s.jpg)
简单说明Java的Struts框架中merge标签的使用方法
2023-09-17 00:32:26
![](https://img.aspxhome.com/file/2023/5/87365_0s.jpg)
用C#来解析PDF文件
2023-11-02 08:07:07
![](https://img.aspxhome.com/file/2023/8/82238_0s.png)
Android SurfaceView预览变形完美解决方法
2021-11-14 10:29:22
Android Studio 引用外部依赖时报错的解决方法
2023-09-26 18:20:11
java中final与finally的使用介绍
2023-04-21 05:36:43
java中超过long范围的超大整数相加算法详解(面试高频)
2022-09-15 11:22:05
![](https://img.aspxhome.com/file/2023/0/61850_0s.png)
Spring Security UserDetails实现原理详解
2023-05-07 01:18:21
![](https://img.aspxhome.com/file/2023/1/80841_0s.png)
springboot用controller跳转html页面的实现
2022-08-15 06:57:51
![](https://img.aspxhome.com/file/2023/1/75711_0s.png)
JAVA熔断和降级真实关系的图文详解
2023-11-30 12:39:20
![](https://img.aspxhome.com/file/2023/7/67957_0s.png)
Android Studio实现带边框的圆形头像
2023-11-30 01:52:23
![](https://img.aspxhome.com/file/2023/6/92576_0s.png)
C#使用SharpZipLib压缩解压文件
2021-10-27 18:56:21
使用@pathvariable与@requestparam碰到的一些问题及解决
2023-11-27 16:30:34
![](https://img.aspxhome.com/file/2023/9/60459_0s.png)
深入理解MyBatis中的一级缓存与二级缓存
2022-05-25 09:41:34
![](https://img.aspxhome.com/file/2023/7/66057_0s.png)
springboot中的静态资源加载顺序优先级
2023-08-24 11:12:31
![](https://img.aspxhome.com/file/2023/6/94206_0s.jpg)