Skip to content

Instantly share code, notes, and snippets.

@hal-gh
Created July 6, 2010 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hal-gh/465934 to your computer and use it in GitHub Desktop.
Save hal-gh/465934 to your computer and use it in GitHub Desktop.
var win = Titanium.UI.currentWindow;
win.backgroundColor = '#fff';
win.layout = 'vertical';
var CONTROL_HEIGHT = 34;
titles = [
{ title: 'This is row 0 (from array)'},
{ title: 'This is row 1 (from array)'},
{ title: 'This is row 2 (from array)'},
{ title: 'This is row 3 (from array)'},
{ title: 'This is row 4 (from array)'},
{ title: 'This is row 5 (from array)'},
{ title: 'This is row 6 (from array)'},
{ title: 'This is row 7 (from array)'},
{ title: 'This is row 8 (from array)'},
{ title: 'This is row 9 (from array)'}
];
var dataArray = [];
for (var i=0; i < 10; i++){
var row = Ti.UI.createTableViewRow({
className: 'todo_row',
height: 50,
width: 'auto'
});
var label = Ti.UI.createLabel({
color:'#222',
top:20,
width: 'auto',
text: titles[i].title
});
row.add(label);
dataArray.push(row);
}
var tableview = Ti.UI.createTableView({
backgroundColor:'#EDECEB',
data:dataArray,
editable:true,
bottom: '50'
});
tableview.addEventListener('click', function(e){
Ti.API.info('tableview eventlistener - you clicked table row index: '+e.index);
Ti.API.info('tableview eventlistener - click source'+e.source);
});
win.add(tableview);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment