Skip to content

Instantly share code, notes, and snippets.

@meeech
Created February 23, 2012 23:22
Show Gist options
  • Save meeech/1895665 to your computer and use it in GitHub Desktop.
Save meeech/1895665 to your computer and use it in GitHub Desktop.
table flicker
// 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