问题
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