I tried to make EditText uneditable with this code:
<EditText android:id="@+id/outputResult"
android:inputType="text"
android:editable="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/result" />
I had to add the following line to make it uneditable, but it didn't seem to have any effect.
android:focusable="false"
Solutip
android:editable="false"
should work, but it's outdated , you should use android:inputType="none"
instead.
You can also do it programmatically.
EditText mEdit = (EditText) findViewById(R.id.yourid);
mEdit.setEnabled(false);
This is also a viable alternative:
EditText mEdit = (EditText) findViewById(R.id.yourid);
mEdit.setKeyListener(null);
If you are going to make your EditText uneditable, may I suggest using a TextView widget instead of EditText, as using EditText seems pointless in that case.
But you also need to consider that when using the setEnable / isEnable function, it will make EditText not work at all, and it cannot even respond to click events, therefore we suggest you use the following method.
android:inputType="none"
android:enabled="false"
android:cursorVisible="false"
android:focusableInTouchMode="false"