[英]I want to display a list of hyperlinked items in Android.
Some items in the list, if clicked, will hyperlink to a URL. 如果单击列表中的某些项目,它们将超链接到URL。 If there is no URL for the associated item, then clicking it should do nothing.
如果没有相关项目的URL,则单击该项目将不执行任何操作。
Should I use a ListView, or is there something better? 我应该使用ListView还是有更好的选择?
Listview
layout with single textview Listview
布局 Arraylist
to hold basically 2 things i. Arraylist
基本上可以保存两件事。 The title of your Hyperlink ii. Adapter
to your ListView
Adapter
设置为您的ListView
ClickListener
to your ListView
ClickListener
设置到您的ListView
eg. 例如。
arraylist.get(postion).name
arraylist.get(postion).url
Now you can just start a WebView using Intents 现在,您可以使用Intents启动WebView
Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Also if you have too many items to be displayed, I would recommend using RecyclerView
另外,如果要显示的项目太多,我建议使用
RecyclerView
我建议您使用RecyclerView ,因此在每个包含TextView属性为android:autoLink="web"
结果项目视图中,也请查看android:linksClickable
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.