首页 > 系统 > Android > 正文

Android EditText默认不弹出输入法的实现方法

2019-10-22 18:17:02
字体:
来源:转载
供稿:网友

一、Android EditText默认不弹出输入法的办法:

1. 在AndroidManifest.xml中将需要默认隐藏键盘的Activity中添加属性即可(常用此方法)

android:windowSoftInputMode="adjustUnspecified|stateHidden"android:configChanges="orientation|keyboardHidden"

例如:

<activityandroid:name=".activity.CheckInfoActivity"android:launchMode="singleTask"android:windowSoftInputMode="adjustUnspecified|stateHidden"android:configChanges="orientation|keyboardHidden"android:screenOrientation="portrait"/>

2. 让 EditText失去焦点,使用EditText的clearFocus方法

EditText edit = (EditText)findViewById(R.id.edit);edit.clearFocus();

3. 强制隐藏Android输入法窗口

EditText edit=(EditText)findViewById(R.id.edit);InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

以上这篇Android EditText默认不弹出输入法的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持VEVB武林网。


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表