Dynamically creating TableViews on click of button
Let me come out very clear. I have some buttons in my Model Window.
var row = Ti.UI.createTableViewRow({height:50});
var row2 = Ti.UI.createTableViewRow({
height:'auto'
});
row2.add(Button);
row2.add(Image);
var data = [开发者_如何学运维row,row2];
var table = Ti.UI.createTableView({
data:data
});
I want 7 TextField dynamically in the first row. The second row remains static but the first one should grow
Do you mean to make an array to be used to create a TableView? Then do something like
function addRow(txtField) {
var tf = Titanium.UI.createTextField({width:100,height:30,hintText:txtField});
var row = Ti.UI.createTableViewRow({height:50});
row.add(rf);
return row;
}
array[0] = addRow('Textfield 1');
array[1] = addRow('Textfield 2');
array[2] = addRow('Textfield 3');
Ti.UI.createTableView({data:array});
精彩评论