How to make an EditText look like a TextView that is done in Java but not in XML..
I have seen how to do it using xml file like
style="@android:style/Widget.TextView"
android:editable="false"
android:cursorVisible="false"
android:longClickable="false"
but i want this to be done in java because i am not using any xml file for the layout.. everything is done in code itself .. I am trying to use GestureListener in my code .. it worked fine for TextView but not EditText So, anything to do for the EditText so that the GestureEvents can be implemented ?
Thanks,
This is perfect way to make EditText as TextView.
Use in your EditText.
<EditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:enabled="false"
android:focusable="false"
android:clickable="false"
android:longClickable="false"
android:inputType="none"/>
EditText
is a subclass of TextView
- so except for editing, what applies to TextView
applies to EditText
as well.
EditText Et; // initialize your edittext//
Et.setCursorVisible(false);
Et.setLongClickable(false);
Et.setClickable(false);
Et.setFocusable(false);
Et.setSelected(false);
Et.setKeyListener(null);
Et.setBackgroundResource(android.R.color.transparent);
And you'll never see it like an EditText again.
add below two line into your edittext xml:
android:focusable="false"
android:inputType="none"
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