0

What do @string & @+id mean?

And why we can't use a String("False") instead of false_button in below ?

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

Thanks.

1 Answers1

3

You can use Strings directly.

 android:text="False"

The @string means it is a value stored in the strings.xml file, with parameter name false_button. It is better practice to do this, for multi language apps. As you can then have multiple xml files for each language, rather than having it hard coded to "False".

As for @+id it means to generate the id with parameter name false_button into an id lookup. As opposed to @id which would come from an already assigned id lookup. @+id is much better, faster, and easier to read.

IAmGroot
  • 13,760
  • 18
  • 84
  • 154
  • 1
    Also, using the strings file allows you to change that value easier. So, if you use "False" everywhere and you want to change it to "True" then you have to change it everywhere if hard-coding. If using the strings.xml then you only have to change that value in one spot. – codeMagic Jun 05 '14 at 23:02