Created
February 8, 2013 11:26
-
-
Save tzhbami7/4738286 to your computer and use it in GitHub Desktop.
der totale krieg!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unction RemoteWindow() { | |
var self = Ti.UI.createWindow({ | |
title:"Load remote Data", | |
backgroundColor:'#fff' | |
}); | |
var resultTbl = Ti.UI.createTableView({ | |
separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.NONE | |
}); | |
self.add(resultTbl); | |
//eventListener focus --> click | |
// | |
self.addEventListener('focus', function() { | |
xhr = Ti.Network.createHTTPClient(); | |
xhr.setRequestHeader("Content-Type", "application/json"); | |
xhr.onload = function() { | |
Titanium.API.info('API.INFO'); | |
var data = JSON.parse(this.responseText); | |
for (var i=0; i < data.length; i++) { | |
var row = Ti.UI.createTableViewRow(); | |
var test_img = Titanium.UI.createImageView({ | |
url: "images/brown_bg_482.png", | |
width: 32, | |
height: 32, | |
left: 4 | |
}); | |
var test_lbl = Titanium.UI.createLabel({ | |
text: data[i].title + " " + data[i].category_title | |
}); | |
row.add(test_img); | |
row.add(test_lbl); | |
resultTbl.appendRow(row); | |
}; | |
}; | |
// open the client | |
xhr.open('GET','http://api.i-v-o.ch/assignments.json'); | |
// send the data | |
xhr.send(); | |
//resultTbl.setData([]); | |
//resultTbl.appendRow(row); | |
}); | |
return self; | |
}; | |
module.exports = RemoteWindow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment