Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML within an Android string resource?

I was wondering if I could place XML within /res/values/strings.xml? I ask this because I am checking for the XML data file for my application, if it does not exist yet then it creates it from the default contents that will be contained as a string resource.

Eclipse tries to change the less than and greater than tags to their corresponding HTML entities when using the GUI to edit the strings. Is eclipse on the right track? Because I should think that it will be written out into my file as HTML entities too. Could I use getText() rather than getString() to convert the entities back into tags?

like image 839
Olical Avatar asked Dec 20 '10 13:12

Olical


People also ask

What is string xml file in Android?

String. xml file contains all the strings which will be used frequently in Android project. String. xml file present in the values folder which is sub folder of res folder in project structure.In Android Studio, we have many Views such as TextView,Button,EditText,CheckBox,RadioButton etc.

Why do we use string xml in Android?

xml , you can easily translate your whole app into other languages. This saves you a lot of work instead of doing this the hardcoded way: Android automatically selects the correct language based on user preferences, and you don't have to worry about selecting and displaying this language.

What is the purpose of strings xml file inside resource directory?

A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.

Where is the strings xml file located?

Open any of your activity's xml file. Press Ctrl Key and move your mouse pointer to the text where it is indicating @string/loginTitle and click. This will open your string. xml file.


1 Answers

Yes you can, just use CDATA

<string name="stringName1"><![CDATA[<html>bla</html>]]></string>

like image 142
Alexander Stolz Avatar answered Sep 28 '22 10:09

Alexander Stolz