使用Android 1.6(4)和2.3.3(10)进行了测试。
我已经制作了一个最简单的测试应用程序来演示这一点,它所做的一切就是用以下内容加载xml:
setContentView(R.layout.main); xml是:
<?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>
问题是:
在将执行期间的实际输入类型设置为textMultiLine(0x00020001)时,我使用调试器对其进行了检查。
另一方面,如果我使用inputType="text",它会像预期的那样工作。
这是Android中的一个bug吗?
发布于 2015-08-10 20:35:26
我也遇到了同样的问题:通过xml定义输入类型不起作用。
然后,为了修复它,我以编程方式设置了输入类型:
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState)
{
...
editText1= (EditText) super.getActivity().findViewById(R.id.editText1);
editText1.setInputType(InputType.TYPE_NULL); // none...
...
}这对我很有效。
发布于 2017-07-06 21:03:43
设置InputType="none“xml不起作用,但是如果您使用数据绑定,那么您可以使用绑定语法来设置输入类型。
导入类型..
<data> <import type="android.text.InputType" /> </data>
然后绑定值
<EditText android:id="@+id/edit_text" android:inputType="@{InputType.TYPE_NULL}" />
发布于 2012-04-18 10:12:04
据我所知,这是android代码中的一个bug。请参阅此处以获取参考- How to make EditText not editable through XML in Android?
GalDude33建议-
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"https://stackoverflow.com/questions/10200950
复制相似问题