|
var win2 = Titanium.UI.createWindow({ |
|
backgroundColor: 'white', |
|
title: 'Main' |
|
|
|
}); |
|
|
|
var win1 = Titanium.UI.iOS.createNavigationWindow({ |
|
window: win2 |
|
}); |
|
|
|
var win3 = Titanium.UI.createWindow({ |
|
backgroundColor: 'blue', |
|
title: 'Blue Window' |
|
}); |
|
Ti.UI.setBackgroundColor('#000'); |
|
var win3 = Ti.UI.createWindow({ |
|
backgroundColor: 'white', |
|
exitOnClose: true, |
|
fullscreen: false, |
|
title: 'TableView Demo' |
|
}); |
|
|
|
// generate random number, used to make each row appear distinct for this example |
|
function randomInt(max){ |
|
return Math.floor(Math.random() * max) + 1; |
|
} |
|
|
|
var IMG_BASE = 'https://github.com/appcelerator/titanium_mobile/raw/master/demos/KitchenSink/Resources/images/'; |
|
var defaultFontSize = Ti.Platform.name === 'android' ? 16 : 14; |
|
|
|
var tableData = []; |
|
|
|
for (var i=1; i<=20; i++){ |
|
var row = Ti.UI.createTableViewRow({ |
|
className:'forumEvent', // used to improve table performance |
|
selectedBackgroundColor:'blue', |
|
rowIndex:i, // custom property, useful for determining the row during events |
|
height:100 |
|
}); |
|
|
|
var imageAvatar = Ti.UI.createImageView({ |
|
image:'http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Mini_Cooper_Facelift_front.JPG/800px-Mini_Cooper_Facelift_front.JPG', |
|
left:1, top:0, |
|
width:107, height:90 |
|
}); |
|
row.add(imageAvatar); |
|
|
|
var labelUserName = Ti.UI.createLabel({ |
|
color:'#576996', |
|
font:{fontFamily:'Arial', fontSize:defaultFontSize+6, fontWeight:'bold'}, |
|
text:'AnteGrup' + i, |
|
left:110, top: 6, |
|
width:200, height: 30 |
|
}); |
|
row.add(labelUserName); |
|
|
|
var labelDetails = Ti.UI.createLabel({ |
|
color:'#222', |
|
font:{fontFamily:'Arial', fontSize:defaultFontSize+2, fontWeight:'normal'}, |
|
text:'Replied to post with id ' + randomInt(1000) + '.', |
|
left:110, top:44, |
|
width:360 |
|
}); |
|
row.add(labelDetails); |
|
|
|
var imageCalendar = Ti.UI.createImageView({ |
|
image:IMG_BASE + 'custom_tableview/eventsButton.png', |
|
left:110, bottom: 2, |
|
width:32, height: 32 |
|
}); |
|
row.add(imageCalendar); |
|
|
|
var labelDate = Ti.UI.createLabel({ |
|
color:'#999', |
|
font:{fontFamily:'Arial', fontSize:defaultFontSize, fontWeight:'normal'}, |
|
text:'on ' + randomInt(30) + ' Nov 2012', |
|
left:145, bottom:10, |
|
width:200, height:20 |
|
}); |
|
row.add(labelDate); |
|
|
|
tableData.push(row); |
|
} |
|
|
|
var tableView = Ti.UI.createTableView({ |
|
backgroundColor:'white', |
|
top:2, |
|
data:tableData |
|
}); |
|
|
|
win3.add(tableView); |
|
|
|
|
|
|
|
|
|
|
|
var button = Titanium.UI.createButton({ |
|
title: 'Open Blue Window' |
|
}); |
|
button.addEventListener('click', function(){ |
|
win1.openWindow(win3, {animated:true}); |
|
}); |
|
|
|
win2.add(button); |
|
|
|
|
|
|
|
|
|
win1.open(); |