Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Change color of a label that is in a tableViewRow

Hi there!

I want to change the color of my label, which is on a tableViewRow, while touched.

I have a tableView called 'listView'. This one i fill up with a array of rows called 'tabledata'. These Rows contain three labels, named each 'rowGroup', 'rowTitle' and 'rowDetail'.

    var row = crTableRow({
    //some stuff not important ;)
    });

    var rowGroup = crLabel({
        color: '#333'
        text: foo
    });

    var rowTitle = crLabel({
        color: '#333'
        text: foo
    });

    var rowDetail = crLabel({
        color: '#333'
        text: foo
    });
    row.add(rowGroup);
    row.add(rowTitle);
    row.add(rowDetail);

    tabledata[z] = row;
    z++;
    listView.data = tabledata;

My eventListeners are looking like this:

listView.addEventListener('touchstart',function(e){

    e.row.rowGroup.color('#FFF'));
    e.row.rowTitle.color('#FFF');
    e.row.rowDetail.color('#FFF'); 
});
listView.addEventListener('touchend',function(e){

    e.row.rowGroup.color('#333');
    e.row.rowTitle.color('#333');
    e.row.rowDetail.color('#333'); 
});

I know that something in my event listeners is wrong, but what?

This is my Error, which appears in the Log:

"Result of expression 'e.row.rowGroup' [undefined] is not an object.";
— asked August 5th 2010 by Michael Gajda
  • click
  • color
  • events
  • iphone
  • row
  • table
  • tableview
  • tableviewrow
  • touch
  • touchend
  • touchstart
0 Comments

1 Answer

  • Accepted Answer

    
    e.row.children[0].color = '#f00';
    
    — answered August 5th 2010 by Dan Tamas
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.