Reputation: 11
I've been searching everywhere for a method that allows one to read a @string value from a text file. I'm not sure if I'm being entirely clear since I cannot seem to describe it in words so I'll use this snippet.
This is a <@string/square_root>
So when I read the file into a textview it includes the square root symbol with it. Is this possible? or if there is another method to do this.
Upvotes: 1
Views: 389
Reputation: 12527
The standard way to do this is to put your string in a resource file, typically res/values/strings.xml (Note below that 221A is the Unicode value of the square root symbol).
<string name="square_root">\u221A</string>
Then you can reference this string from either an XML layout file:
<TextView android:text="@string/square_root" ...>
Or from Java code:
Context context = this; // in this example the current activity is the context
String title = context.getString(R.string.square_root);
TextEdit textEdit = ....
textEdit.setText(title);
For more information, see: http://developer.android.com/guide/topics/resources/string-resource.html
Upvotes: 1