1

I have a string containing a URL which I would like to make bold. For some reason when I add the bold tags - the text still does not appear in this manner.

I'm sure it is something very simple. Does anyone know how this can be resolved?

Example:

<string name="updated_text">This is sample text. If this doesn’t work, go to<b> <a href="news.google.com">http://news.google.com</a></b> to find more infomation.</string>
8
  • No... If you look at the method I'm using - and look at the example you just showed - they look almost exactly the same: it isn't working (with the bold tag) Commented Oct 22, 2013 at 18:31
  • The accepted answer there uses Html.fromHtml(), which you do not appear to be using. String XML does not support the <a> tag, as per the String Resources documentation. Commented Oct 22, 2013 at 18:33
  • What about the bold tags? Commented Oct 22, 2013 at 18:41
  • While the bold should work, the parser may be giving up on formatting once it finds the <a> tag. Start by removing the <a> tag and see if that fixes the bold. Though since you probably want to keep that, you may also just want to move to a slightly different implementation now. Commented Oct 22, 2013 at 18:43
  • I used <string name="updated_text">This is sample text. If this doesn’t work, go to<b> news.google.com</b> to find more infomation.</string> and it still isn't appearing bold Commented Oct 22, 2013 at 18:47

1 Answer 1

0

try it like this , this should work

myTextView.setText(Html.fromHtml(getResources().getString(R.string.updated_text)));
Sign up to request clarification or add additional context in comments.

2 Comments

Ok. How about the bold tags in my question?
I used <string name="updated_text">This is sample text. If this doesn\’t work, go to<b> news.google.com</b>; to find more infomation.</string> and it still isn't appearing bold

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.