Reputation:
i did not put some text in string.xml and there is a yellow alert symbol in side of Textview field. i want to know does it have problem and what happen, if do not put texts in string.xml in android?
Upvotes: 0
Views: 180
Reputation: 35661
Whilst it will not cause a problem in the short term, it is not good practice and will cause you issues in the future if you decide to support multiple languages.
Upvotes: 1
Reputation: 463
Nothing will happen.
string.xml used to:
I Recommend you to put text files in string.xml
Upvotes: 1
Reputation: 1346
Well, setting your text directly on your layout file can be a source of future problems and its not recommended.
Consider this scenario: You use the same string "Foo" in many layout files and then you decided to change to "Bar". If you have hardcoded that, you will need to make changes in all layout files and there might be a chance to leave some inconsistent text. But if you place it in the strings.xml
file, you will have only to change in one place.
Also, if you want to add translations to your app, the Android system can handle it automatically for you if you use the strings.xml
.
You might want to take a look here and here.
Upvotes: 1