简体   繁体   English

如何在Java Android Studio中更改对EditText的自动对焦?

[英]How to change Auto Focus on EditText in Java Android Studio?

I call the function to open the dialog. 我调用该函数以打开对话框。 Dialog boxes have two EditText . 对话框有两个EditText When I open the dialog box, the keyboard automatically pops up. 当我打开对话框时,键盘会自动弹出。 How can I disable this behavior? 如何禁用此行为? I only need to open the keyboard when the EditText receives a touch event. 我只需要在EditText收到触摸事件时打开键盘。

on your onCreate() method 在您的onCreate()方法上

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

If you want all your activity use soft keyboard use this in your manifest file for your all activities 如果您希望所有活动都使用软键盘,请在清单文件中使用它进行所有活动

<activity
    android:configChanges="keyboardHidden|orientation"
    android:windowSoftInputMode="stateHidden" />

Add this lines in your Androidmanifest.xml file android:windowSoftInputMode="stateHidden" 将此行添加到您的Androidmanifest.xml文件中android:windowSoftInputMode="stateHidden"

Example :- 例子 :-

<activity
            android:name=".Registration_Screen"
            android:windowSoftInputMode="stateHidden" >
        </activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM