The goal of the custom implementation of Html.TagHandler is to enable the processing of tags that are not processed by the Android framework. Therefore, in order to do what you want, one way is to replace all the tags that you want to process with another tag that, as you know, the framework will not process, so it will go into your implementation. For example, you can make a method like this to prepare html:
public string prepareHTMLForTagHandling(string htmlSource) { if (htmlSource == null || htmlSource == "") return null; return htmlSource.replace("<a", "<acustomlink") .replace("</a>", "<acustomlink>"); }
And then use it like:
Html.fromHtml(prepareHTMLForTagHandling(myHtml), null, myHtmlCustomTagHandler);
Finally, in your custom tag handler implementation, you are processing "acustomlink" as a tag instead of "a".
Hope this helps.
source share