Difference between “@id/” and “@+id/” in Android

前端 未结 13 1967
悲&欢浪女
悲&欢浪女 2020-11-22 01:20

What is the diffirence between the @id/ and @+id/?

In @+id/ the plus symbol

13条回答
  •  盖世英雄少女心
    2020-11-22 02:11

    From the Developer Guide:

    android:id="@+id/my_button"
    

    The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file). There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:

    android:id="@android:id/empty"

提交回复
热议问题