Skip to content

Instantly share code, notes, and snippets.

@meeech
Forked from nauman/app.js
Created October 16, 2012 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meeech/3896836 to your computer and use it in GitHub Desktop.
Save meeech/3896836 to your computer and use it in GitHub Desktop.
Titanium header - > title, content -> table, footer -> banner
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
backgroundColor: 'red',
exitOnClose: true,
navBarHidden: true
});
var titleView = Ti.UI.createView({
backgroundColor: '#f00',
top: 0,
left: 0,
right: 0,
height:45
});
var label = Ti.UI.createLabel({
text:'Title Here',
font:{fontSize:14},
color:'#444',
height:Ti.UI.SIZE,
width:Ti.UI.FILL
});
titleView.add(label);
var bannerView = Ti.UI.createView({
backgroundColor: '#0f0',
bottom: 0,
left: 0,
right: 0,
height:45
});
// 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<=11; i++){
var row = Ti.UI.createTableViewRow({
className:'forumEvent', // used to improve table performance
selectedBackgroundColor:'white',
rowIndex:i, // custom property, useful for determining the row during events
height:110
});
var imageAvatar = Ti.UI.createImageView({
image: IMG_BASE + 'custom_tableview/user.png',
left:10, top:5,
width:50, height:50
});
row.add(imageAvatar);
var labelUserName = Ti.UI.createLabel({
color:'#576996',
font:{fontFamily:'Arial', fontSize:defaultFontSize+6, fontWeight:'bold'},
text:'Fred Smith ' + i,
left:70, 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:70, top:44,
width:360
});
row.add(labelDetails);
tableData.push(row);
}
var tableView = Ti.UI.createTableView({
backgroundColor:'white',
data:tableData,
top: 45,
bottom:45
});
win.add(titleView);
win.add(tableView);
win.add(bannerView);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment