"无标签视图指向此文本字段"警告消息的含义

use*_*702 35 android android-lint

这个警告是什么意思?

没有标签视图使用android:labelFor ="@ id/@ id/editText1"属性指向此文本字段

请注意,double id(@id/@id)是错误消息文本的问题,并不反映XML内容(这是正确的语法).

Mir*_*nes 20

labelFor是辅助功能选项的属性.您将此分配给标签,以便在表单上,​​用户单击textedit字段时,android可以知道要向用户读取什么(TalkBack).

您分配给它的ID似乎不是有效的.为什么@idid中有两个?使用这样的ID:@id/editText1


小智 18

我有同样的警告信息.当我向EditText添加提示时,它消失了

android:hint="Some explanation about the input..."
Run Code Online (Sandbox Code Playgroud)

  • 对于任何寻找日食角色的人来说,这里都是`......`. (3认同)

sti*_*ike 13

虽然我不熟悉您发布的确切错误.但这听起来肯定是你做错了textView.在你的使用中使用id如下textView.

android:id="@+id/editText1"
Run Code Online (Sandbox Code Playgroud)

如果你想设置labelFor然后使用:

   android:labelFor="@+id/editText1"
Run Code Online (Sandbox Code Playgroud)

  • 你不应该在"labelFor"id中加号.它应该是:android:labelFor ="@ id/editText1"加号只用一次来生成id. (5认同)
  • @wholladay如果你在创建id之前尝试引用id,这很重要.要么添加+,要么重新组织xml元素. (2认同)

YEH*_*YEH 6

这意味着您可能应该为此编辑文本定义标签,并使用标签定义中的labelFor链接它们.

示例代码:

<TextView
    android:id="@+id/my_textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:labelFor="@+id/my_editText" <!--the plus sign goes first in the code-->
    android:text="I'm a label" />

<EditText
    android:id="@id/my_editText" <!--no plus sign if not the first-->
    android:layout_width="wrap_content"
    android:inputType="text"
    android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

它不仅适用于文本视图.