防止 EditText 自动对焦 [英] Prevent EditText from automatically focusing
本文介绍了防止 EditText 自动对焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Android Activity,整个布局中有一个 EditText
.出于某种原因,每当活动开始时,键盘就会出现.我已经尝试了所有以下的事情:
I have an Android activity and there is one EditText
in the whole layout. For some reason, whenever the activity starts, the keyboard comes up.
I have tried all of the following things:
将这两个放在
OnStart
中:
FindViewById<EditText> (Resource.Id.searchText).ClearFocus ();
FindViewById<EditText> (Resource.Id.searchText).Selected = false;
添加具有这两个属性的LinearLayout
:
android:focusable="true" android:focusableInTouchMode="true"
在布局上的另一个 View
中添加以下标签:
android:focusable="true" android:focusableInTouchMode="true"
将此添加到我的活动清单中:
Adding this to my activity manifest:
android:windowSoftInputMode="stateHidden"
但是仍然,当活动打开时键盘会打开.我可能做错了什么?
But still, the keyboard opens when the activity opens. What could I be doing wrong?
推荐答案
试试这个 -this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
这篇关于防止 EditText 自动对焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文