If you are working in non editable EditText
, then you may notice that now it’s showing warning in xml layout file, Because android:editable
is now editable deprecated android. And it will be removed in upcoming version of android. And if you navigate to official website then they will suggest you to use android:inputType
instead of android:editable
.
But they haven’t explained that how to use android:inputType
to disable input in EditText.
So here is solution:
first method is using android:inputType
which is suggested by official android team. To use this just set android:inputType="none"
and it will become non editable.
<EditTextandroid:id="@+id/myEditText"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="Hint"android:inputType="none"/>
In your xml code set focusable="false"
, android:clickable="false"
and android:cursorVisible="false"
and this will make your EditText treat like non editable.
<EditTextandroid:id="@+id/myEditText"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="Hint"android:focusable="false"android:clickable="false"android:cursorVisible="false"/>
If you can also disable EditText, then you can set this from Java or Kotlin code.
EditText et = findViewById(R.id.myEditText);et.setEnabled(false);
myEditText.isEnabled = false
Quick Links
Legal Stuff
Social Media