Hiding the android keyboard for EditText

前端 未结 10 2031
慢半拍i
慢半拍i 2020-12-17 14:27

Whenever I click in the EditText the Android keyboard popup window appears, but I don\'t want the keyboard to pop up.

I want to permanently hide the and

相关标签:
10条回答
  • 2020-12-17 15:16

    Try to add this in yout onCreate() method.

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

    Not tested but It Should work!!

    0 讨论(0)
  • 2020-12-17 15:19

    Works for all Android versions.

    In your XML use the property android:textIsSelectable="true"

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        .
        .
        .
        android:textIsSelectable="true"/>
    

    And, in your Java class:

    editText1.setShowSoftInputOnFocus(false);
    

    In Kotlin:

    editText1.showSoftInputOnFocus = false
    
    0 讨论(0)
  • 2020-12-17 15:24

    These two line should do what you want:

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    
    0 讨论(0)
  • 2020-12-17 15:28

    You may try to fake your EditText with a Button like this:

     <Button
         android:id="@+id/edit_birthday"
         style="@android:style/Widget.EditText"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:hint="@string/hint_birthday"/>
    
    0 讨论(0)
提交回复
热议问题