Android 设置Edittext获取焦点并弹出软键盘
作者:AndroidKun 时间:2022-02-28 12:02:02
Android 设置Edittext获取焦点并弹出软键盘
/**
* EditText获取焦点并显示软键盘
*/
public static void showSoftInputFromWindow(Activity activity, EditText editText) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
ps:android页面进入edittext自动获取焦点,弹出软键盘解决方法
在edittext的父布局中加入上面2个属性
android:focusable="true"
android:focusableInTouchMode="true"
来源:http://blog.csdn.net/a1533588867/article/details/53185390
标签:edittext
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java流程控制之循环结构for,增强for循环
2023-11-03 10:45:20
![](https://img.aspxhome.com/file/2023/4/58834_0s.jpg)
Java压缩文件工具类ZipUtil使用方法代码示例
2022-11-26 02:21:32
C# 实现FTP客户端的小例子
2022-06-09 13:19:13
![](https://img.aspxhome.com/file/2023/6/91366_0s.png)
Java Stopwatch类,性能与时间计时器案例详解
2023-07-24 04:08:50
spring boot 使用profile来分区配置的操作
2022-11-27 22:55:15
![](https://img.aspxhome.com/file/2023/5/64205_0s.png)
C#使用Monitor类实现线程同步
2021-07-20 03:01:14
![](https://img.aspxhome.com/file/2023/3/67553_0s.png)
Springboot 整合shiro实现权限控制的方法
2021-09-21 20:15:47
c# 所有类型都从Object类型派生
2022-08-13 21:22:58
探讨Object转为String的几种简易形式详解
2023-08-21 11:47:27
Android的异步任务AsyncTask详解
2021-10-13 02:58:28
Java 语言实现清除带 html 标签的内容方法
2021-07-29 23:47:43
Spring钩子接口汇总分析使用示例
2022-09-24 23:29:56
android通过usb读取U盘的方法
2023-03-14 07:43:25
Java Switch对各类型支持实现原理
2023-10-28 04:45:37
java实现猜字母游戏
2021-11-19 22:25:28
解析在C#中接口和类的异同
2022-04-10 13:02:07
![](https://img.aspxhome.com/file/2023/6/68096_0s.png)
利用Java简单实现一个代码行数统计器方法实例
2023-01-12 10:50:25
![](https://img.aspxhome.com/file/2023/0/79860_0s.png)
SpringMVC 域对象共享数据的实现示例
2021-07-18 15:45:57
![](https://img.aspxhome.com/file/2023/6/75016_0s.png)
Java AtomicInteger类使用方法实例讲解
2023-01-18 16:22:49
Android实现自动提取短信验证码功能
2022-11-19 23:58:49
![](https://img.aspxhome.com/file/2023/1/106811_0s.jpg)