I'm getting the following error in hello world activity 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 out.
It allows you to easily locate text in your app and later have it translated. Strings can be internationalized easily, allowing your application to support multiple languages with a single application package file (APK).
Hardcoded string are the literal strings. So, What you may be referring to is, literal strings in the data. C# // Instead of var myStr = Home + "123"; // Using this var myStr = "Test123"; The problem doesn't show up, unless we have to use this string literal in multiple places.
This is not an error, this is a Lint warning. So you can run the App, but the recommended way to display texts(on TextViews, Buttons etc.) is to use string references. You have to go to your res folder and there will be a strings.xml file under values. Add this in there:
<string name="my_string">Your Text!</string>
And to set text on you button you then have to do this:
android:text="@string/my_string"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With