Search code examples
androidandroid-xml-attribute

Why doesn't the "@string/" attribute not have a + sign?


I know that the + sign in the id attribute of a View indicates that it's a new user defined custom value that must be added to the R.Java file. But, in the example XML Button View attributes below, why does the @string not have the + symbol before the word string like the @+id attribute?

<Button android:id="@+id/my_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/my_button_text"/>

Solution

  • The plus symbol, +, indicates that this is a new resource ID and the Android Asset Packaging Tool will create a new resource integer in the R.java class, if it doesn't already exist.

    @string - Defined in resource files. The <string> element's name is used as the resource ID.