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
.
If you want your disabled EditText to look the same as your enabled one, you should use android:enabled="false" in combination with android:textColor="..." . Show activity on this post. Used this if you have an icon to be clickable, this works for me.
For the above requirement the solution in XML is android:editable="false" but I want to use this in Java. et. setKeyListener(null); It makes the EditText not EDITABLE but at the same time it makes it non clickable as well.
Android Studio:EditText editable is deprecated How to use inputType.
Simply use toString() on the Editable instance to get String.
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" .
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"
/>
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With