Dynamically create labels, how?
Since we can't change the font on the tableView, I'm looking at using labels instead. However, I'm not sure how to have them dynamically created.
Here is my code that does the data, but I'm not sure where in it I would put a createLabel (and use the title for the display).
.
.
.
while (rows.isValidRow()) {
data.push({
id: rows.fieldByName('id'),
lat: rows.fieldByName('lat'),
lon: rows.fieldByName('lon'),
title: rows.fieldByName('caption'),
info: rows.fieldByName('info'),
hasChild: true
.
.
.
1 Answer
-
This is how I add table row with two fields and different fonts
var row = Ti.UI.createTableViewRow({ layout : 'vertical', height : 'auto', width : UserManager.userList.size.width - 1, className : "@row" }); var row_user_string = Ti.UI.createLabel({ text : user_string, top : 5, left : 15, right : 5, width : UserManager.userList.size.width - 1, font : { fontWeight : 'bold', fontSize : '16px' }, height : 25 }); row.add(row_user_string); var row_user_email = Ti.UI.createLabel({ text : user_email, top : 2, left : 15, width : UserManager.userList.size.width - 1, right : 5, font : { fontSize : '16px' }, height : 25 }); row.add(row_user_email); // Add the row to data array dataArray[i] = row;
pretty straight forward