EditText软键盘弹出问题解决
当带有EditView的activity第一次进入时,第一个EditText框会自动获得焦点,这个严重影响了用户体验,但是如何去掉呢??
查阅了很多资料后,发现以下方法最简单:?
在xml中,在EditText控件之前?
加入?
<LinearLayout?
??? android:id="@+id/linearLayout_focus"?
??? android:focusable="true"?
??? android:focusableInTouchMode="true"?
??? android:layout_width="0px"?
??? android:layout_height="0px"/>?
这是一个虚假的LinearLayout,不会显示的,但是会抢走焦点?
?
?
手动隐藏软键盘:
?
final InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE); ? ? ? ?
imm.hideSoftInputFromWindow(mSearchEt.getWindowToken(), 0); ??