安卓:我如何添加一个ListView里面的HTML链接? [英] Android: How can I add HTML links inside a ListView?

查看:206
本文介绍了安卓:我如何添加一个ListView里面的HTML链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会去加入一个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...

这篇关于安卓:我如何添加一个ListView里面的HTML链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆