1

my string.xml string line

 <string name="companyLink">&lt;a href=&quot;http://www.abc.com&quot;&gt;abc Technology &lt;/a> </string>

and this is how i try to use the html

    TextView   companylink = (TextView) findViewById(R.id.textViewCompanyLink);
    companylink.setText(Html.fromHtml(getString(R.string.companyLink)));
    companylink.setMovementMethod(LinkMovementMethod.getInstance());

however android only display out the html without the hyperlink on the screen

<a href=http://abc.com>abc string </a>
ericlee
  • 2,703
  • 11
  • 43
  • 68
  • Have you tried changing the all `&` to `&`? You don't need to escape the ampersand character when using it in a HTML entity. That might be causing issues. – Alex Curran Aug 02 '12 at 14:17
  • see [this](http://stackoverflow.com/questions/9852184/android-textview-hyperlink/9852280#9852280) – Andrei Aug 02 '12 at 15:44

2 Answers2

3

The quotes should also be escaped otherwise Java will remove them during getString(). Add backslashes before &quot;

<string name="companyLink">&lt;a href=\&quot;http://www.abc.com\&quot;&gt;abc Technology &lt;/a> </string>

Or this solution that worked for me:

https://stackoverflow.com/a/9949264/1011746

Community
  • 1
  • 1
mindriot
  • 14,149
  • 4
  • 29
  • 40
1

I believe the correct syntax is:

<a href="http://abc.com">abc string </a>

Warpzit
  • 27,966
  • 19
  • 103
  • 155