Created
February 23, 2012 23:22
-
-
Save meeech/1895665 to your computer and use it in GitHub Desktop.
table flicker
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
// create table view data object | |
var win = Ti.UI.createWindow({ | |
backgroundColor: "#ccc" | |
}); | |
var data = []; | |
function addRow(text, detailtext){ | |
var textContainer = Ti.UI.createView({ | |
height: 'auto', | |
top: 0, | |
left: 40, | |
right: 40, | |
layout: 'vertical' | |
}); | |
textContainer.add(Ti.UI.createLabel({ | |
text: text, | |
height: 'auto', | |
font: { | |
fontSize: 14 | |
}, | |
left: 0, | |
right: 0, | |
bottom: 5 | |
})); | |
textContainer.add(Ti.UI.createLabel({ | |
text: detailtext, | |
height: 'auto', | |
font: { | |
fontSize: 12 | |
}, | |
left: 0, | |
right: 0, | |
bottom: 5 | |
})); | |
var tr = Ti.UI.createTableViewRow({ | |
height: 'auto' | |
}); | |
tr.add(textContainer); | |
return tr; | |
}; | |
for (var i=0; i < 10; i++) { | |
var lt = (i%2 == 0) ? 'Lorem ipsum dolor sit amet' : 'qui officia deserunt mollit anim id est laborum'; | |
var dt = (i%2 == 0) ? 'I was angry with my friend: I told my wrath.' : 'qui officia deserunt mollit anim id est laborum qui officia deserunt mollit anim id est laborum qui officia deserunt mollit anim id est laborum'; | |
data.push(addRow(lt,dt)); | |
}; | |
// create table view | |
var tableview = Titanium.UI.createTableView({ | |
minRowHeight:45 | |
}); | |
tableview.setData(data); | |
// add table view to the window | |
win.add(tableview); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment