How to embed link tag in textview using RSS in a Android

99封情书 提交于 2019-12-24 17:17:01

问题


I had made a basic rss reader that reads the feed and display it in listview, then i further tried to improve it by adding tabs and writing a custom adapter,now the next step i want to achieve is to provide the basic capability that whenever a headline (displayed through a textview) is clicked/touched the link associated with it (link has been extracted throught he rss/xml) is launched in the browser. Now, i know that launching the link into browser is an easy one step affair using URI, whats causing trouble is how do i keep the link with the textview it is associated with?

I have implemented the onclicklistener all i need to figure out is how can the retrieval of relevant link can be achieved so that i can make a URI out of it and launch it in the browser. Any help would be highly appreciated.

Thanks


回答1:


You should create a wrapper object with the title and the url. then fill the list view with those objects, and get the url to fire the browser activity.

Something like:

class RssObect {
    string title;
    string url;

    //contructors

    //getters and setters
}

Then on the adapter set the list something like List<RssObect> list = getRssFeed(...).... Then on item click listener just use the current item selected (list.get(selected).getUrl());



来源:https://stackoverflow.com/questions/11600480/how-to-embed-link-tag-in-textview-using-rss-in-a-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!