2015-07-13 94 views
0

我打電話給該功能打開對話框。對話框有兩個EditText。當我打開對話框時,鍵盤自動彈出。我如何禁用此行爲?當EditText收到觸摸事件時,我只需要打開鍵盤。如何更改Java Android Studio中的EditText的自動焦點?

+0

http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup?rq=1 – Satya

+0

[可以停止EditText auto-focus?](http ://stackoverflow.com/questions/11732545/can-stop-edittext-auto-focus) –

+0

檢查這些鏈接 http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus特技的活動的啓動 http://stackoverflow.com/questions/11732545/can-stop-edittext-auto-focus 的http:// stackoverf low.com/questions/18295802/how-to-make-edittext-not-focused-when-creating-activity –

回答

1

您onCreate()方法

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

如果您希望您的所有活動中使用軟鍵盤在清單文件中將其用於所有活動

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

工作很棒!!!! – sabish

0

添加此行AndroidManifest.xml檔案android:windowSoftInputMode="stateHidden"

: -

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