Hi, I have a problem, I created a table view on one page (page.js) that loads data from XHR (here's the code):
var win = Ti.UI.currentWindow; function createwindow(itemList) { var section = Ti.UI.createTableViewSection(); var tableView = Titanium.UI.createTableView({ top:20, bottom:52, width:320, height:344, data:[], style:Titanium.UI.iPhone.TableViewStyle.PLAIN, backgroundColor:'transparent' }); for (var c=0;c < itemList.length;c++){ var datas= []; datas[0] = section; var row = Titanium.UI.createTableViewRow({ height:'50', selectedBackgroundColor:'#b40000', className: "row_" + c, hasChild:true }); var title = null; var cell_bck = '#fff'; var squadra_casa = itemList.item(c).getElementsByTagName("squadracasa").item(0).text; var squadra_fuori = itemList.item(c).getElementsByTagName("squadrafuori").item(0).text; var squadraLabelL = Titanium.UI.createLabel({ text:squadra_casa, width:100, top:3, left: 30, height:44, textAlign:'left', color:'#fff', font:{ fontFamily:'Trebuchet MS',fontSize:13,fontWeight:'normal' } }); var squadraLabelR = Titanium.UI.createLabel({ text:squadra_fuori, width:95, top:3, left: 185, height:44, textAlign:'right', color:'#fff', font:{ fontFamily:'Trebuchet MS',fontSize:13,fontWeight:'normal' } }); row.add(squadraLabelL); row.add(squadraLabelR); section.add(row); } tableView.setdata([]); tableView.setData(datas); win.add(tableView); }; function loadXml () { var url = 'http://www.myserieb.it/feed_matches.php'; xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() { var xml = this.responseXML; var channel = xml.documentElement.getElementsByTagName("channel"); feedTitle = channel.item(0).getElementsByTagName("title").item(0).text; Titanium.UI.currentWindow.title = feedTitle; var itemList = xml.documentElement.getElementsByTagName("item"); Ti.API.info('found '+itemList.length+' items in the RSS feed'); createwindow(itemList); }; xhr.open('GET',url); xhr.send(); }; loadXml () ;the page with the table view, is launched from the home as well:
var liveWindow = Titanium.UI.createWindow({ title:'Live', backgroundColor:'black', tabBarHidden: false, navBarHidden: false, barColor: '#000', backgroundImage: '../img/stagioneBackgroundNero.png', url: "page.js" }); liveButton.addEventListener('click', function(e) { Titanium.UI.currentTab.open(liveWindow,{animated:true}); });The first visit to that page all ok. But if I go out and return the table view has problems. on the page it seems there are two table view overwritten. I have read many post around about the same problem but none that solve my problem. Can you help me? Thank you all
1 Answer
I us iOS. I have made a table that works correctly the first time I open it.
When I exit and get back the second time I find the table open correctly but find another one that covers the newly built table. I'm closing the window in this way.
var b = Titanium.UI.createButton({ title:'Chiudi', style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN }); win.setLeftNavButton(b); b.addEventListener('click',function() { win.close(); });
Your Answer
Think you can help? Login to answer this question!