Hello I am wondering if there is a way to change a string value in my xml code without touching the .java file
e.g.
in case i have in the strings.xml
<string name="title"> This is my title</string>
If I can change inside my main.xml file
The string to have the value: This is my title
meaning to have the third word of my string on bold
Thank you
In your strings.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title"> This is <b>my</b> title</string>
</resources>
Related
I have a question about values/strings.xml
I'd like to use strings.xml, but use another strings.xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
<string name="test">veeeeeeeeeeeeeeeeeeeeeeeery long script(about 1000characters)</string>
</resources>
like this, when I want to manage veeeeery long script by another xml file.
Then can I use another .xml file in values/strings.xml file?
for example like..
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
<string name="test"> #values/script.xml </string>
</resources>
Thank you for reading my question.
Have a nice day :)
Yes, you just need to use #string instead of #values
I am trying to leave an empty line in a string resource
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">"Hello\nWorld!"</string>
</resources>
The above just puts "world" in the next line, but I need to leave an empty line. any help or sugestion would be great.
try
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">"Hello\n\nWorld!"</string>
</resources>
How to add apostrophe in Android String Resource File?
Hi!,
I'm trying to add apostrophe (') in android strings
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Stack's Answers</string>
</resources>
Try:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Stack\'s Answers</string>
</resources>
You have to escape the XML with a \ before the apostrophe because it is a character that has a special meaning in Android's XML.
Try this way..
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Stack\'s Answers</string>
</resources>
I want to support multiple languages in my app using sqlite database and xml resources.
For example, the user can insert transaction objects. Each transaction has a category.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="categories">
<item>#string/category1</item>
<item>#string/category2</item>
<item>#string/category3</item>
<item>#string/category4</item>
<item>#string/category5</item>
</array>
</resources>
What is the correct approach to use the above values in sqlite? Should a table be created or I can use them directly from xml?
If I want the user to be able to also add his own categories, how the multi-language thing should work?
Please read the two following google guides about supporting different languages and localizing:
http://developer.android.com/training/basics/supporting-devices/languages.html
http://developer.android.com/guide/topics/resources/localization.html
the normal way is to create a strings.xml for every language:
For Storing your categories in your SQLite Database you should enumerate your Categories and store only the numbers, so you are independent of the spelling. Adding a user defined Catergory should also work this way.
MyProject/
res/
values/
strings.xml
values-es/
strings.xml
/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">My Application</string>
<string name="hello_world">Hello World!</string>
</resources>
/values-es/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">Mi AplicaciĆ³n</string>
<string name="hello_world">Hola Mundo!</string>
</resources>
Hi, I'm also doing the same tutorial
http://www.vogella.de/articles/Android/article.html#first_uiproperties.
I've managed to add strings to my strings.xml and it shows up calculate but when I go to resource chooser and try to add it to the button its not there. So what I did was create another string called time and then went back into my graphical layout and try to add it to a button and that doesn't show up. I've saved the project but that doesnt help I've also tried adding several strings but none of them show up in my resources chooser.
Any help would be much appreciated.
Here is my strings.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestApp</string>
<string name="fahrenheit">to Fahrenheit</string>
<string name="action_settings">Settings</string>
<color name="myColor">#F5F5F5</color>
<string name="hello_world">Hello world!</string>
<string name="celsius">to Celsius</string>
<string name="calculate">to Calculate</string>
</resources>
Remove the colour
check if u have imported android.R if u have imported in the change the import to your R file.
clean the project.