700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 含EditText组件的界面中 禁止自动弹出软键盘

含EditText组件的界面中 禁止自动弹出软键盘

时间:2021-03-25 23:00:58

相关推荐

含EditText组件的界面中 禁止自动弹出软键盘

解决方法:

1)在Manifest.xml文件中相应的activity下添加一下代码:

android:windowSoftInputMode="stateHidden"

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);

4).EditText始终不弹出软件键盘

例:EditText edit=(EditText)findViewById(R.id.edit);

edit.setInputType(InputType.TYPE_NULL);

5)在EditText标签的外层Layout中加入focusableInTouchMode属性

例:<LinearLayout android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:focusableInTouchMode = "true">

<EditText>...</EditText>

</LinearLayout>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。