Difference between android:id and android:labelFor?

后端 未结 5 626
春和景丽
春和景丽 2020-12-25 10:37

I wrote a simple layout which has an EditText, but it\'s showing the following warning message:

“No label views point to this text field”

5条回答
  •  甜味超标
    2020-12-25 11:15

    android:id

    Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). This must be a resource reference; typically you set this using the @+ syntax to create a new ID resources. For example: android:id="@+id/my_id" which allows you to later retrieve the view with findViewById(R.id.my_id).

    Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

    This corresponds to the global attribute resource symbol id.


    android:labelFor

    public static final int labelFor

    Specifies the id of a view for which this view serves as a label for accessibility purposes. For example, a TextView before an EditText in the UI usually specifies what infomation is contained in the EditText. Hence, the TextView is a label for the EditText.

    Must be an integer value, such as "100".

    This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

    Constant Value: 16843718 (0x010103c6)

    UPDATE:

    For example -

     
        
         
         
        
      
    

    Reference: android:id and android:labelFor.

提交回复
热议问题