"Hard line xxx must use @string resource"

I get the following error in the world’s welcome code:

Description Resource Path Location Type [I18N] Hardcoded string "and this is a clickable button!", should use @string resource activity_hello_world.xml/HelloWorld/res/layout line 21 Android Lint Problem 

Please help me.

+6
source share
2 answers

This is not a mistake, this is a Lint warning. Thus, you can run the application, but the recommended way to display texts (in TextViews, Buttons, etc.) is to use string links. You have to go to your res folder and there will be a strings.xml file under the values. Add here:

  <string name="my_string">Your Text!</string> 

And to set the text on the button you have to do this:

 android:text="@string/my_string" 
+14
source

example- (on the keyboard)

put this under the string.xml file in the values ​​folder

 <string name="keypad_title">Keypad</string> 

put this code under keypad.xml in the layout folder

 <Button android:id="@+id/keypad_1" android:text="1"> </Button> 
0
source

All Articles