How can I disable typing in an EditText
field in Android?
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
Right click the text area and untick the editable option:
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
try this Kotlin code,
editField.isEnabled = !editField.isEnabled
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.