Skip to content

Instantly share code, notes, and snippets.

@mauropm
Created July 25, 2013 19:59
Show Gist options
  • Save mauropm/6083201 to your computer and use it in GitHub Desktop.
Save mauropm/6083201 to your computer and use it in GitHub Desktop.
Adding a reference of the elements inside a row, so you can programmatically remember how to access a certain label or image. To use this app: create a new project in Ti Studio, using a classic titanium project, copy this to app.js and run it in emulator. Check the "try to print a custom value in the row". That's the way you will be able to acce…
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
var tableData = [];
for (var i=1; i<=20; 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,
avatar: null,
username: null,
details: null,
});
var imageAvatar = Ti.UI.createImageView({
image: 'KS_nav_ui.png',
left:10, top:5,
width:50, height:50
});
row.add(imageAvatar);
row.avatar = imageAvatar;
var labelUserName = Ti.UI.createLabel({
color:'#576996',
text:'Fred Smith ' + i,
left:70, top: 6,
width:200, height: 30
});
row.add(labelUserName);
row.username = labelUserName;
var labelDetails = Ti.UI.createLabel({
color:'#222',
text:'Replied to post with id...',
left:70, top:44,
width:360
});
row.add(labelDetails);
row.details = labelDetails;
// Try to print a custom value in the row.
Ti.API.info(row.details);
tableData.push(row);
}
var tableView = Ti.UI.createTableView({
backgroundColor:'white',
data:tableData
});
win.add(tableView);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment