Search code examples
androidtitaniumtableviewappcelerator

Appcelerator tableView font color


How can you set the color of the font for the rows in tableView?

I DO NOT want to set it row by row like this:

var table_data = [
    {title:'Row 1', color: 'black'},
];

I have tried adding font:{colour:'black'} to the table var but it does not seem to work. Like this:

var table1 =  Titanium.UI.createTableView({
  data:table_data,
  separatorColor:'black',
  font:{color:'black'}
});

I want to be able to set it so any row in the table has a set color. Specifically as I will be adding items to the table and I want them to be 'black' not the default white/grey. So when I add new items they will be black...

I am sure this is simple but I cant seem to find anything that is assisting me hence the question here

Thanks in advance.


Solution

  • here you go.Add a lable in tableview row and set it according to your own desire

    var self = Ti.UI.createWindow({
        backgroundColor : 'white',
        title : 'Saved Locations'
    });
    var data = [];
    var tabLoc = Ti.UI.createTableView({
    });
    self.add(tabLoc);
    var row = Titanium.UI.createTableViewRow({
        height : '60dp',
        className : "tableRow",
    });
    var labTitle = Ti.UI.createLabel({
        color : 'black',
        font : {
            fontSize : '12dp',
            fontWeight : 'bold'
        },
        height : Ti.UI.SIZE,
        text : 'There is no location yet saved',
        textAlign : 'center'
    });
    
    row.add(labTitle);
    data.push(row)
    tabLoc.setData(data);
    self.open()
    

    Thanks