问题
I have a TextView
that I am populating with a Spannable
made from some HTML.
This code:
textView.setText(Html.fromHtml(textContent, mImageGetter, null));
displays links, but they aren't clickable. This code:
text.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(Html.fromHtml(textContent, mImageGetter, null));
doesn't display the links. The TextView
is specified in the XML as
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/another_textview"
android:layout_marginTop="5dp"
android:autoLink="web"
android:textColorLink="@color/link_color_unpressed"
android:textColor="#ffffff"
android:textSize="18sp" />
Why does LinkMovementMethod
, a method that exists entirely to make links in a TextView
clickable, stop links from displaying?
回答1:
The culprit was the auto-link method:
<TextView
...
android:autoLink="web"
...
/>
Removing this line fixed the problem.
来源:https://stackoverflow.com/questions/15299147/textviewsetmovementmethodlinkmovementmethod-getinstance-is-breaking-link-di