Created
July 2, 2012 20:31
-
-
Save grantges/3035526 to your computer and use it in GitHub Desktop.
Creating a tableview in appcelerator with multiple views per row
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Create Your Window | |
*/ | |
var win = Ti.UI.createWindow({ | |
title: 'MainWin', | |
backgroundColor: '#a6a6a6' | |
}); | |
/* | |
* Array to hold Table Data | |
*/ | |
var rowData = []; | |
/* | |
* Create some Table Rows | |
*/ | |
for(var i=0; i<10; i++){ | |
var row = Ti.UI.createTableViewRow({ | |
height: 100, | |
width: Ti.UI.FILL, //'auto' is deprecated as of Ti Mobile SDK v2.0 - use Ti.UI.SIZE or Ti.UI.FILL | |
layout: 'horizontal', | |
selectionStyle: Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE | |
}); | |
/* | |
* Create some default Views, add them to your TableViewRow | |
*/ | |
for(var k=0; k<4; k++) { | |
var view = Ti.UI.createView({ | |
height: 90, | |
width: 72, | |
left:6, | |
top: 5, | |
backgroundColor: '#ececec', | |
borderColor: '#000', | |
border: 1, | |
}); | |
row.add(view); | |
} | |
/* | |
* Update the data array with the TableViewRow you just created | |
*/ | |
rowData.push(row); | |
} | |
/* | |
* Create Your TableView, add the data previously created | |
*/ | |
var tableView = Ti.UI.createTableView({ | |
height: Ti.UI.FILL, | |
width: Ti.UI.FILL, | |
backgroundColor: 'transparent', | |
separatorColor: 'transparent', | |
data: rowData | |
}); | |
/* | |
* Add the tableView 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