我怎么会去加入一个ListView内可点击的链接?
How would I go about adding clickable links inside a ListView?
使用一个TextView的自动链接属性,这可以。我花了一些时间,通过文件来挖,因此把这里的情况下,别人的一个例子是寻找它:
This is done using the autoLink attribute of a TextView. Took me some time to dig through the documentation so putting it here with an example in case someone else is looking for it:
让我们假设你正在你的ListView绑定到一个自定义的适配器。在这种情况下,下面这段code进入你的getView电话:
Let us assume that you are binding your listview to a custom adapter. In that case, the following piece of code goes into your getView call:
code:
textcontent.setText(Html.fromHtml(item.get_text()));
textcontent.setAutoLinkMask(Linkify.WEB_URLS);
只要把里面的文字链接传递给的setText电话,你就大功告成了。
Just put the link inside the text being passed to the setText call and you're done.
XML:
<TextView
android:id="@+id/txtview"
android:autoLink="web"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="put your link here"/>
希望有所帮助......
Hope that helps...