Tested with Android 1.6(4) and 2.3.3(10).
I've made a minimalistic test application to demonstrate this, all it does is load the xml with:
setContentView(R.layout.main);
and the xml is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:ems="10" >
</EditText>
The problem:
when setting inputType="none"
the actual input type during execution becomes textMultiLine(0x00020001)
, I've checked it with a debugger.
On the other hand if I use inputType="text"
it works as expected.
Is this a bug in Android?
I had the same problem: defining the input type via xml did not work.
Then, to fix it, I set the input type programatically:
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState)
{
...
editText1= (EditText) super.getActivity().findViewById(R.id.editText1);
editText1.setInputType(InputType.TYPE_NULL); // none...
...
}
That works for me.
Setting InputType="none" xml doesn't work, but if you're using databinding then you can use the binding syntax to set Input type.
import the type..
<data>
<import type="android.text.InputType" />
</data>
then bind the value
<EditText
android:id="@+id/edit_text"
android:inputType="@{InputType.TYPE_NULL}" />
Use android:editable="false"
. Even though it's deprecated, it works when inputType doesn't.
From what I can tell this is a bug in the android code. see this for refrence - How to make EditText not editable through XML in Android?
GalDude33 suggests-
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
Use this
textView.setKeyListener(null);
User contributions licensed under CC BY-SA 3.0