我搜索了堆栈溢出并按照解决方案但仍然没有得到我想要的。 我从这样的服务器接收String
<p><a href="http://www.arenafootball.com/sports/a-footbl/aflsrk/mtt/micheaux_robinson_841978.html"><span style="font-size: small;"><strong>AFL Stats</strong></span></a></p>
现在我尝试使用TextView
tv.setText(Html.fromHtml(""))
中显示它
代码:
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(Html.fromHtml("myrecivedString"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
XML:
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"
android:linksClickable="true" />
预期输出:
它的可点击但在我的Android应用程序中输出不可点击。我的代码有什么问题?
答案 0 :(得分:1)
tv.setText( Html.fromHtml("your string"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
并且不要在XML中的TextView上使用android:autoLink="all"
。然后尝试它应该工作.....