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

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

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

In @+id/ the plus symbol

13条回答
  •  青春惊慌失措
    2020-11-22 02:15

    The plus sign (+) before the resource type is needed only when you're defining a resource ID for the first time. When you compile the app, the SDK tools use the ID name to create a new resource ID in your project's R.java file that refers to the EditText element. With the resource ID declared once this way, other references to the ID do not need the plus sign. Using the plus sign is necessary only when specifying a new resource ID and not needed for concrete resources such as strings or layouts. See the sidebox for more information about resource objects.

    From: https://developer.android.com/training/basics/firstapp/building-ui.html

提交回复
热议问题