Hello, I seek a way to add color to my tablevieuw. Two colors, yellow, orange, yellow, orange ...
indicate two colors in my tableView and then it automatically generates my tablevieuw with my colors
Can you help me please?
thank you
4 Answers
Accepted Answer
Hello IVedia,
you can do it with using one Flag like
var win = Ti.UI.createWindow({ }); var table = Ti.UI.createTableView({ }); win.add(table); var data = []; var viewcolor = true; for (var i = 0; i < 10; i++) { var row = Ti.UI.createTableViewRow({ height : 40 }); if(viewcolor){ row.backgroundColor = 'yellow' ; }else{ row.backgroundColor = 'orange' ; } viewcolor = !viewcolor; data.push(row); } table.data = data; win.open();just try this code....
If any problem then feel free to ask again....
Best luck.
Sarfaraz Babi thank you, it works very well your code
thank you very much
Thank you delos santos Nash, but I do not use a sql database I note your source thank you too ;)
Good day to all
:)
Can you tell me how to change the color of the bottom tableview, I think the default color is 'e0e0e0'
but I would love to put eg 'ff0000'
thank you
Hi, IVIedia,
if you are getting data from sql, try this on your while loop:
// make your sql query first var listArray = []; var odd = '#2d5285', even = '#5a779e'; while (rows.isValidRow()) { var color = (id%2) ? odd:even; var lRow = Ti.UI.createTableViewRow(); lRow.backgroundColor = color; var name = Ti.UI.createLabel({ text: rows.fieldByName('fieldname'), height: 30, left: 20, font: { fontSize: 15}, color: '#fad2c0' }); lRow.add(name); listArray.push(lRow); rows.next(); }
Your Answer
Think you can help? Login to answer this question!