Android Studio:EditText editable is deprecated How to use inputType
I want to realize
android:editable="false"
But it told me editable is deprecated ,you can use inputType
instead.
So I don't know how to realize it by using inputType
.
Use
android:clickable="false"
. but In case you want to use onclick listener for it. don't use
android:clickable="false"
.. Use
android:cursorVisible="false" android:focusable="false" .
The Code
In XML
<EditText
android: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"
/>
The Result
Java Code
You can achieve the same result at runtime with this code
EditText et = findViewById(R.id.myEditText);
et.setFocusable(false);
et.setClickable(false);
et.setCursorVisible(false);
If you are using any input type that is not kind of text or number like date or date and time you can use android:inputType="date"
or android:inputType="datetime"
or android:inputType="time"
. If you are not using any such kind of input type you can use android:inputType="none"
.