Reputation: 3
I have a string-array in strings.xml. How can I underline the string in item?
For string we do like this..
<string name="clickable_string">This is a <u>clickable string</u></string>
I tried something like this.
<string-array name="products">
<item>this is a <u> clickable</u> string </item>
<item> <u> clickable</u> string </item>
<item>this is a <u> clickable</u> string </item>
</string-array>
Its not working. How can I do that? Thank you
Upvotes: 0
Views: 809
Reputation: 11107
Try this way it will work
<string-array name="description">
<item> <Data> <![CDATA[ Check this <u>Redirect to Next Activity</u> ]]></Data> </item>
</string-array>
In java Code use this :
ArrayList<String> title_list = new ArrayList<String>();
String[] description_Array = getResources().getStringArray(R.array.description);
String categoryAndDesc = null;
for(String cad : description_Array) {
categoryAndDesc = cad;
title_list.add(categoryAndDesc);
}
CharSequence sequence = Html.fromHtml(categoryAndDesc);
seperator_view.setText(strBuilder);
seperator_view.setMovementMethod(LinkMovementMethod.getInstance());
Upvotes: 2
Reputation: 19723
Try this:
<string name="clickable_string">This is a <u>clickable string</u></string>
(i.e) Replace the < and > with <; and >; in your strings.xml for HTML formatted content.
And in your code use:
String text = context.getString(R.string.clickable_string);
myTextView.setText(Html.fromHtml(text));
Upvotes: 1