var mainWindow = Ti.UI.createWindow({ layout: 'vertical', backgroundColor: '#d4d4d4', exitOnClose: true, }); var mainWindowView = Ti.UI.createScrollView({ contentHeight: 'auto', layout: 'vertical', }); var mainHeaderPhoto = Ti.UI.createImageView({ top: 0, image: '/images/header.jpg', width: '100%', }); var tableView = Ti.UI.createTableView({data:[], backgroundColor:'transparent'}); var client = Ti.Network.createHTTPClient({ onload : function(e) { var news = eval('(' + this.responseText + ')'); news = news[i].posts; for (var i=0; i<=20; i++){ var data = []; var row = Ti.UI.createTableViewRow({ backgroundColor:'transparent', hasChild: true, title: news.title, fontSize: 24, color:"#fff", height:110 }); data.push(row); }; tableView.setData(data); }, onerror : function(e) { Ti.API.debug(e.error); alert('error'); }, timeout : 5000 }); client.open("GET", "http://*******"); // Send the request. client.send(); mainWindowView.add(mainHeaderPhoto); mainWindowView.add(tableView); mainWindow.add(mainWindowView); mainWindow.open();Here's the code, but still don't have data on my table. I tried putting it on alert, it works. Help. It's for android.
↧
Put json data to tableview
↧