I have a EditText in which the user should not be able to provide input. So I tried disabling it,by
edittext.setEnabled(false); edittext.setClickable(false);
But still when I press the "next" button in the softKeyboard from some other EditText it directs me to the one which should not be editable and I am able to insert values into it. How to avoid this?
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.
To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library.
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.
setEnabled(false); , in combination with editText. setFocusable(false); will achieve this. The same works with XML: android:enabled="false" and android:focusable="false" . Thanks guys!
This works fine; just set focusable property of your edittext to "false" and you are done.
<EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText>
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