开发者

How to use Linkify text in this case

I have an activity which contains 2 textviews and an imageview. First textview contains the title, second contain description and in imageview corresponding image. In description part if any of th开发者_JAVA百科e listed title come across it should be linkify and onclick it should create a page containing the title and corresponding description. It should work like wikipedia. I have stored all title and desc in string array.

I tried following this link... Android: Launch activity from clickable text

     UnderlineSpan[] underlines = strBuilder.getSpans(UnderlineSpan.class);

But I am getting error: The method getSpans(int, int, Class) in the type SpannableStringBuilder is not applicable for the arguments (Class)

How can i solve this problem? Or is there easier way to linkify between two different activities?

Thanks..


You need to add a start and end, like getSpans(0,strBuilder.length(),UnderlineSpan.class).


Try this,

SpannableString content = new SpannableString("hello");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
txtView.setText(content);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜