linkmovementmethod

Is there a standard way to have hrefs and telephone numbers clickable in a TextView?

泄露秘密 提交于 2019-12-12 02:03:07
问题 I already know how to use TextView to automatically create clickable links for web addresses, phone numbers, etc.. My question is when you have HTML with hrefs in it as well as phone numbers and you want both clickable, is there a better or more standard way of doing it? Here is what I have: String text = "Click <a href=\"http://stackoverflow.com\">Stackoverflow</a> or call 1-234-567-8901."; TextView textView = getTextView(); textView.setLinksClickable(true); textView.setMovementMethod

TextView#setMovementMethod(LinkMovementMethod.getInstance()) is breaking link display

醉酒当歌 提交于 2019-12-11 02:31:39
问题 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