How to Disable Edittext in Android

How to disable EditText in Android

I think its a bug in android..It can be fixed by adding this patch :)

Check these links
question 1
question 2

Hope it will be useful.

Disabling of EditText in Android

I believe the correct would be to set android:editable="false".

And if you wonder why my link point to the attributes of TextView, you the answer is because EditText inherits from TextView:

EditText is a thin veneer over
TextView that configures itself to be


As mentioned in the comments below, editable is deprecated (since API level 3). You should instead be using inputType (with the value none).

Enable/Disable editText with a Switch in Android Studio

You can set the OnCheckedChangeListener of the switch.

switchGaranzia.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
} else {

Unable to disable EditText programmatically in kotlin android

You should use isEnabled.

Set the enabled state of this view.

 panEditText.isEnabled =false

Method Overview

public void setEnabled(boolean enabled) {
if (enabled == isEnabled()) {

if (!enabled) {
// Hide the soft input if the currently active TextView is disabled
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);


if (enabled) {
// Make sure IME is updated with current editor info.
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) imm.restartInput(this);

// Will change text color
if (mEditor != null) {

// start or stop the cursor blinking as appropriate

EditText: how to enable/disable input?

I finally found a solution. It's a matter of calling

  • setFocusableInTouchMode(boolean)
  • setFocusable(boolean)

when the EditText is first created, so it can intercept the clicks. Then one can set those flags back again to make the EditText editable, request the focus, and manually show/hide the soft keyboard with InputMethodManager methods

Related Topics

Leave a reply