Andro Selva Andro Selva - 3 months ago 12
Android Question

How to make an EditText uneditable/disabled

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?

Answer

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>
Comments