Skip to content Skip to sidebar Skip to footer

How Set Textview Text Both Clickable And Selectable?

My textview load html text that contains links (to website, to e-mail address ...) tv = (TextView)((Activity)mContext).findViewById(R.id.entry_webview); tv.setText(Html.fromHtml(my

Solution 1:

I had the same issue - this solution works for me:

The XML TextView should not have any link/selectable attributes:

<TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"/>

Then, set everything programmatically respecting the following order:

textView.setText(Html.fromHtml(myHtml));
Linkify.addLinks(textView, Linkify.WEB_URLS);
textView.setTextIsSelectable(true); // API-11 and above
textView.setMovementMethod(LinkMovementMethod.getInstance());

Solution 2:

have you tried using something like this tv.setText(Html.fromHtml("<a href='url'>link</a>"));

Post a Comment for "How Set Textview Text Both Clickable And Selectable?"