setMovementMethod 在 android textview 中不起作用 [英] setMovementMethod doesn't work in android textview
问题描述
我有一个文本视图,其文本来自数据库.该文本可以是普通文本,也可以是链接或两者兼而有之.为此,我使用 Html.fromHtml(myText)
解析 html 中的文本.这样就可以检测到该链接并将其显示为可点击的.这工作正常.它显示链接的可点击字符串和普通文本不可点击的字符串.但是当我单击该文本时,它不起作用并且没有任何反应.这是我从服务器获得的文本:
I have a textview whose text is coming from database. This text can be normal text or it can be a link or both. For this, I am parsing text in html using Html.fromHtml(myText)
. So that link can be detected and display as clickable. This is working fine. It displays clickable string for links and non-clickable for normal text. But when I click that text, it doesn't work and nothing happens. This is what I am getting from server as text :
Dear user:
Your review titled <a href="http://example.com/review/someText-1069459" target="blank">Normal verified negative 1 desktop</a> on the product <a href="http://example.com/product-reviews/text-925766045" target="blank">Clickable Text</a> has been resolved.
To check corporate response <a target="blank" href="http://example.com/interact.php?add=http://example.com/blog/ejhhspsqmn/Please-talk-about-your-companys-products-and-services-onlyPlease-present-your-post-in-an-objectiv&session_id=Se9qExA6JSY%3d">Click here</a>
Have a great day!
Regards,
Head - Member Support
为了制作可点击的文本,我使用 setMovementMethod 如下:
textView.setText(Html.fromHtml(myText));
textView.setMovementMethod(LinkMovementMethod.getInstance());
但它不起作用.有什么我想添加的代码吗?另外我在 xml 中使用 android:autoLink="web"
.
But its not working. Is there anything that I am missing to add in code ? Also I am using android:autoLink="web"
in xml.
推荐答案
删除 xml 中的 android:autoLink="web".
Remove the android:autoLink="web" in xml.
这篇关于setMovementMethod 在 android textview 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!