Android TextView enable LinkiFy and Href tags
I w开发者_如何学Cant to set a text to the textview which contains href tags as well as normal http links. For ex, text like this "please <a href=/'http://google.com' target='_blank'>click here</a>. or visit http://yahoo.com".
The issue is I am unable to set both properties together. If I set Html.fromHtml to the text, the link with the href tag is highlighted. But the Linkfy property is not working for "http://yahoo.com" and vice versa. Is there any default property to enable both href tags and normal links in a TextView.
Thanks,
I couldn't find one myself as I worked through a similar situation with HREFs and telephone numbers; in lieu of anything better, I am currently using a custom REGEX for calling Linkfiy.addLinks. Calling Linkify.addLinks with a mask "also removes any existing URLSpans attached to the Spannable", which were created by Html.fromHtml. See the Linkify Documentation.
If it's possible using an mx controls Label (spark does not support this any longer) u can use htmlText like the following example:
import mx.controls.Label //class need to be imported
var textview:Label = new Label();
textview.htmlText = "please <a href=/'http://google.com' target='_blank'>click here</a>. or visit http://yahoo.com";
yourItemContainer.addElement(textview);
This should work. But I don't know if it's possible for u using a normal label.
精彩评论