开发者

Edittext android automatic focus

开发者 https://www.devze.com 2023-02-22 07:30 出处:网络
I have an issue when the activity starts, android automatically places focus on开发者_运维问答 the first edittext. How do I prevent android from doing that? Have a look here

I have an issue when the activity starts, android automatically places focus on开发者_运维问答 the first edittext. How do I prevent android from doing that?


Have a look here

Or you could just hide the keyboard, focus remains on the EditText upon starting the activity:

android:windowSoftInputMode="stateHidden"


use setFocusable (boolean focusable) to prevent. http://developer.android.com/reference/android/view/View.html#setFocusable(boolean)


Three ways to solve this..

  1. Set these attributes to the parent..

And now, when activity starts this layout getting default focus.

Also we can remove focus from children views in runtime (e.g. after finishing child editing):

findViewById(R.id.mainLayout).requestFocus(); or

Look in the AndroidManifest.xml element.

android:windowSoftInputMode="stateHidden"

It always hide key board when entering the activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消