Recently someone here helped me get my feed working with the default Kitchen Sink RSS example (Simon Kok thank you!). Ever since I've been trying to make each row when clicked open up a detail view with just the article title and body text (rather than a URL of the actual webpage provided in the example).
I thought it would be quite easy, but I may have taken on something bigger than my programming skills can handle! Any help, thoughts, suggestions or code examples appreciated (below is what I have so far).
Thanks John
// create table view data object var data = []; var xhr = Ti.Network.createHTTPClient(); xhr.open("GET","http://sciencefictionworld.com/index.php?format=feed&type=rss"); xhr.onload = function() { try { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("item"); var x = 0; var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue; for (var c=0;c<items.length;c++) { var item = items.item(c); var title = item.getElementsByTagName("title").item(0).text; var row = Ti.UI.createTableViewRow({height:80}); var label = Ti.UI.createLabel({ text:title, left:72, top:5, bottom:5, right:5 }); row.add(label); data[x++] = row; row.url = item.getElementsByTagName("link").item(0).text; } var tableview = Titanium.UI.createTableView({data:data}); Titanium.UI.currentWindow.add(tableview); tableview.addEventListener('click',function(e) { var w = Ti.UI.createWindow({title:doctitle}); var wb = Ti.UI.createWebView({url:e.row.url}); w.add(wb); var b = Titanium.UI.createButton({ title:'Close', style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN }); w.setLeftNavButton(b); b.addEventListener('click',function() { w.close(); }); w.open({modal:true}); }); } catch(E) { alert(E); } }; xhr.send();
Your Answer
Think you can help? Login to answer this question!