titanium tableview font color

301 views Asked by At

How to change the font-color in a TableView. Other elements can be changend with the color attribute.

When i run the app on my Android Phone the table is displayed, but the font-color is still grey/white. There are also no table borders. I want to set the color to black.

// create an array of anonymous objects
var tbl_data = [
    {title:'Row 1'},
    {title:'Row 2'},
    {title:'Row 3'}
];
// now assign that array to the table's data property to add those objects as rows
var table = Ti.UI.createTableView({
    data:tbl_data,
    color: '#000000'
});

amountView.add(table);
1

There are 1 answers

1
turtle On BEST ANSWER

According to Titanium docs; TableView does not have color property.

What you can do is create TableViewRow and add them to TableView; and finally applying TableViewRow's color property. Example below:

var tableData = [],
    win = Ti.UI.createWindow();

    tableData.push(Ti.UI.createTableViewRow({ title: 'Apples', color : "#000" }));
    tableData.push(Ti.UI.createTableViewRow({ title: 'Bananas', color : "#000" }));
    tableData.push(Ti.UI.createTableViewRow({ title: 'Carrots', color : "#000" }));
    tableData.push(Ti.UI.createTableViewRow({ title: 'Potatoes', color : "#000" }));

var table = Ti.UI.createTableView({
    data: tableData
});

win.add(table);
win.open();