How can I change the text color in a table view row when I touch a different row in real time.

Hi!

I’m using widgets 2.0. I have a table view and when I’m touching a row the text color change. When  I’m touching a different row the text color change too but the previous text change to his original only if I scroll the table view and the row dissapears from the screen and appears again (I’m using the params table to manipulate the color of the text object between the onRowRender and the onRowTouch functions).

I think the solution is to run a for loop to change the color of all row texts except from the target or to change the color of previous row from the onRowTouch function. But I can’t find a way to have access onRowTouch to the text objects of the other rows.

thanks a lot.

In your onRowTouch you can listen for the “release” and tap phases and set the row’s color back if you want it to reset when they lift the finger.  If not, you will have to loop over all rows, reset them, then set the color on the currently touched row.

Rob

Thanks for your responce Rob.

My problem is the access of all row text objects in onRowTouchFunction in order to run a for loop. I don’t know the syntax. Is this correct: tableView._view._rows[i].textObject:setTextColor(0, 0, 0)?

In your onRowTouch you can listen for the “release” and tap phases and set the row’s color back if you want it to reset when they lift the finger.  If not, you will have to loop over all rows, reset them, then set the color on the currently touched row.

Rob

Thanks for your responce Rob.

My problem is the access of all row text objects in onRowTouchFunction in order to run a for loop. I don’t know the syntax. Is this correct: tableView._view._rows[i].textObject:setTextColor(0, 0, 0)?

Have you found a solution?  I’m attempting to do something similar and have not been able to.

tableView._view._rows[i].textObject:setTextColor(0, 0, 0)

This will only work for Graphics 1.0.  It’s now setFillColor() in Graphics 2.0

This will only work if you create an object in the row called textObject and add it to the row table:

row.textObject = display.newText(…)

Rob

Have you found a solution?  I’m attempting to do something similar and have not been able to.

tableView._view._rows[i].textObject:setTextColor(0, 0, 0)

This will only work for Graphics 1.0.  It’s now setFillColor() in Graphics 2.0

This will only work if you create an object in the row called textObject and add it to the row table:

row.textObject = display.newText(…)

Rob

Hi,

If you want to change the text, use this:

tableView._view._rows[i]._view.textObject.text = a text

setFillcolor it’s work in graphics 2.0  :stuck_out_tongue:

Hi,

If you want to change the text, use this:

tableView._view._rows[i]._view.textObject.text = a text

setFillcolor it’s work in graphics 2.0  :stuck_out_tongue: