I\'m trying to make an app with localisation built in, but I want a way that I can create a web link within the text, the URL being defined elsewhere (for ease of maintenanc
The problem is your "a href" link tags are within strings.xml
and being parsed as tags when strings.xml
is parsed, which you don't want. Meaning you need to have it ignore the tags using XML's CDATA:
And then you can continue with Html.fromHtml()
and make it clickable with LinkMovementMethod
:
TextView tv = (TextView) findViewById(R.id.textHolder);
tv.setText(Html.fromHtml(getString(R.string.sampleText)));
tv.setMovementMethod(LinkMovementMethod.getInstance());