
Untitled
By: a guest on
May 3rd, 2012 | syntax:
None | size: 2.39 KB | hits: 22 | expires: Never
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({ title:'Tab 1' });
var tab1 = Titanium.UI.createTab({
icon: 'KS_nav_views.png',
title: 'Tab 1',
window: win1
});
var index = 0;
var data = [];
//create an initial section with four rows
data[index] = Ti.UI.createTableViewSection({
headerTitle: "This is the first section"
});
for (i = 0; i < 4; i++) {
var rowLabel = Ti.UI.createLabel({
text: "This is row " + i,
height: 'auto',
width: 270,
left: 10,
right: 0,
top: 10,
bottom: 10,
font: { fontSize: 14 }
});
var sectionRow = Ti.UI.createTableViewRow({
height: 'auto'
});
sectionRow.add(rowLabel);
data[index].add(sectionRow);
}
index++;
//create a second section, with no header and just a large label
data[index] = Ti.UI.createTableViewSection({
headerTitle: ""
});
var row = Ti.UI.createTableViewRow({
height: 'auto',
selectionStyle: 0
});
var label = Ti.UI.createLabel({
text: "label start\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nlabel end",
height: 'auto',
width: 270,
left: 10,
right: 0,
top: 10,
bottom: 10,
font: { fontSize: 14 }
});
row.add(label);
data[index].add(row);
index++;
//create a third and final section with four rows
data[index] = Ti.UI.createTableViewSection({
headerTitle: "This is the third section"
});
for (var j = 0; j < 4; j++) {
var rowLabel = Ti.UI.createLabel({
text: "",
height: 'auto',
width: 270,
left: 10,
right: 0,
top: 10,
bottom: 10,
font: { fontSize: 14 }
});
var rightButton = Ti.UI.createButton({
style: Ti.UI.iPhone.SystemButton.DISCLOSURE
});
var sectionRow = Ti.UI.createTableViewRow({
height: 'auto'
//rightImage: 'some_image.png'
});
sectionRow.add(rowLabel);
sectionRow.add(rightButton);
data[index].add(sectionRow);
}
index++;
//add it all to the table
var tableview = Titanium.UI.createTableView({
data: data,
style: Titanium.UI.iPhone.TableViewStyle.GROUPED,
minRowHeight: 40,
top: 0
});
//add the tableview to the window, then the window to the tabGroup
win1.add(tableview);
tabGroup.addTab(tab1);
tabGroup.open();