How to prevent keyboard from appearing for EditText that is not enabled

In my activity there is an EditText , which supposedly is not edited until the user clicks on the edit button for the screen.

I did edit.setEnabled(false) , but the keyboard is still displayed for the user, and the values ​​can be added to the EditText on the screen from the keyboard, although the screen may look a little gray. What else do I need to do to prevent the EditText from being edited until the user clicks the edit button.

Thanks Steve

+6
source share
6 answers

Attention that setEditable disabled.

You can use:

 setInputType(EditorInfo.TYPE_CLASS_TEXT) 

Turn on the keyboard.

 setInputType(EditorInfo.TYPE_NULL) 

To disable the keyboard.

+26
source

Try setEditable(false) in your EditText.

Set it to true when you want someone to enter it.

+1
source

in your layout file add this attribute to your EditText

android:editable="false"

+1
source

To make EditText Write Only and not appear on the keyboard, I use these two commands in a .xml file.

  android:editable="false" android:inputType="none" 
+1
source

Use edittext.setInputType (0); in your java file.

0
source

Added EditText function in API 21, namely

 editText.setShowInputOnFocus(boolean show); 

This is exactly what you need.

0
source

Source: https://habr.com/ru/post/888600/


All Articles