欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

EditText / This text field does not specify an inputType or a hint

发布时间:2025/7/14 编程问答 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 EditText / This text field does not specify an inputType or a hint 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我是一个警告,xml代码是:

<EditTextandroid:id="@+id/str_ipaddress"android:layout_width="wrap_content"android:layout_height="wrap_content"android:ems="10"android:inputType="text" />

改成

<EditTextandroid:id="@+id/str_ipaddress"android:layout_width="wrap_content"android:layout_height="wrap_content"android:ems="10"android:inputType="text"android:labelFor="@id/str_ipaddress" />

就好了。

为什么,因为新版本SDK要求填写属性lableFor,类似于填写一个ID来绑定这个控件,第一句已经添加了一个id,直接用那个就行了

 

 

 

This text field does not specify an inputType or a hint

1 <EditText 2 android:layout_width="fill_parent" 3 android:layout_height="wrap_content" 4 android:minLines="3" 5 android:id="@+id/message" 6 />

        这样写的时候突然发现有黄色的叹号出现,提示:"This text field does not specify an inputType or a hint";

        原因是这个编辑框缺少一个属性:hint。

        hint属性作用如下:

       

    修改后代码为:   

1 <EditText 2 android:layout_width="fill_parent" 3 android:layout_height="wrap_content" 4 android:minLines="3" 5 android:hint="@null" 6 android:id="@+id/message" 7 />

   添加后黄色叹号就消失了。

转载于:https://www.cnblogs.com/chen-lhx/p/3963658.html

《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读

总结

以上是生活随笔为你收集整理的EditText / This text field does not specify an inputType or a hint的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。