user3105313
user3105313

Reputation:

what happen if do not put text files in string.xml in android?

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

Answers (3)

Kuffs
Kuffs

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

user1528799
user1528799

Reputation: 463

Nothing will happen.

string.xml used to:

  1. localization res/values-fr/strings.xml res/values-ja/strings.xml
  2. ease of editing and to save memory when reusing.

I Recommend you to put text files in string.xml

Upvotes: 1

diegocarloslima
diegocarloslima

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

Related Questions