sarah
sarah

Reputation: 265

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 the 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..

Upvotes: 1

Views: 810

Answers (2)

Lalit Poptani
Lalit Poptani

Reputation: 67296

Try this,

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

Upvotes: 1

Ben Williams
Ben Williams

Reputation: 6167

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

Upvotes: 3

Related Questions