In a project, when you enter a page, EditText automatically gets the focus by default.
So how do you cancel this default behavior?
On the internet for a long time, a bit of listening to soft keyboard events, a little call Clearfouse () method, but the test is not! The corresponding attribute could not be found in XML to close this default behavior
Solution: Find one in EditText's parent control, set it to
Android:focusable= "true"
Android:focusableintouchmode= "true"
In this way, the default behavior of EditText is truncated!
<linearlayout
style= "@style/fillwrapwidgetstyle"
android:orientation= "Vertical"
android:background= "@color/black"
Android:gravity= "Center_horizontal"
android:focusable= "true"
android:focusableintouchmode= "true"
>
<imageview
Android:id= "@+id/logo"
style= "@style/wrapcontentwidgetstyle"
android:background= "@drawable/dream_dictionary_logo"
/>
<relativelayout
style= "@style/fillwrapwidgetstyle"
android:background= "@drawable/SEARCHBAR_BG"
Android:gravity= "Center_vertical"
>
<edittext
Android:id= "@+id/searchedittext"
style= "@style/wrapcontentwidgetstyle"
Android:background= "@null"
Android:hint= "Search"
android:layout_marginleft= "40DP"
Android:singleline= "true"
/>
</RelativeLayout>
</LinearLayout>
From: http://blog.csdn.net/woshicaixianfeng/article/details/7261718 Grey often thanks to this classmate ...
There is also a way to implement this feature very simply:
The Clearfocus () of the EditText object;
Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Imm.hidesoftinputfromwindow (Editmsgview.getwindowtoken (), 0); (off soft keyboard ...) )
How Android lets EditText not automatically get focus