Created
May 4, 2011 16:27
-
-
Save TheBrousse/955520 to your computer and use it in GitHub Desktop.
Titanium Image List View
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
var win = Ti.UI.currentWindow; | |
// Images to display (this list can be dynamically generated) | |
var images = [ 'image1.png', 'image2.png', 'image3.png', 'image4.png', | |
'image5.png',' image6.png', 'image7.png', 'image8.png' ]; | |
// Empty table data (will be populated at runtime) | |
var data = []; | |
var table = Ti.UI.createTableView(); | |
// Loop through the images collection (2 images at a time) | |
for (var i=0; i < images.length; i+=2) { | |
// Empty Table Row | |
var row = Ti.UI.createTableViewRow(); | |
// The image on the left of the row | |
var imageLeft = Ti.UI.createImageView({ | |
url: images[i], | |
left: 10, | |
top: 2, | |
width: 100, | |
height: 100 | |
}); | |
// The image on the right of the row | |
var imageRight = Ti.UI.createImageView({ | |
url: images[i+1], | |
left: 190, | |
top: 2, | |
width: 100, | |
height: 100 | |
}); | |
// Add the two images to the newly created row | |
row.add(imageLeft); | |
row.add(imageRight); | |
// A mut for performance reasons | |
row.className = 'two_images_per_row'; | |
// Add the row to the data variable | |
data.push(row); | |
} | |
// Fill the table with the data variable | |
table.setData(data); | |
win.add(table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment