Monday, December 19, 2011

Titanium Table creation with click event


http://developer.appcelerator.com/question/122206/double-click-textfield-in-tableview-to-fire-click-event
win = Titanium.UI.createWindow({
    backgroundColor:'white',
    fullscreen:false
});
 
tableView = Titanium.UI.createTableView();
 
var dataArray = [];
for(var i=0; i<10; i++){
    var row = Titanium.UI.createTableViewRow();
 
    var label = Titanium.UI.createLabel({
        text:'THIS IS LABEL  ' + i,
        width:100,
        height:'auto'
    });
    var textBox = Titanium.UI.createTextField({
        right:5,
        width:30
    })
 
    row.add(label);
    row.add(textBox);
 
    dataArray.push(row);
}
 
var lastRow;
tableView.addEventListener('click', function(e){
    lastRow = e.row;
    if(lastRow){
        lastRow.backgroundColor='white';
    }
    e.row.backgroundColor='red';
})
 
 
tableView.setData(dataArray);
 
win.add(tableView);
win.open();

No comments:

Post a Comment