error setfillcolor on tableview scroll

hi…

I’m triyng to change row color in a tableview and i have followed this topic :

https://forums.coronalabs.com/topic/40774-tableview-highlight-row-selected/ 

The code works fine, but when i try to scroll table view appears this error : attempt to call method setfillcolor .

Why that? 

How can i solve this issue? 

this is my code 

local function onRowTouch( event ) local phase = event.phase local row = event.target local par = event.row.params if "press" == phase then for i = 1, myList:getNumRows() do if i == row.index then myList.\_view.\_rows[i].\_rowColor.default = { 1, 0,0 } else myList.\_view.\_rows[i].\_rowColor.default = {1,1,1} end end myList:reloadData() end end myList = widget.newTableView { top = 54, width = 410, height = 270, onRowRender = onRowRender, onRowTouch = onRowTouch } for i = 1, #data do myList:insertRow{ rowHeight = 15, rowColor = { default = { 232, 232, 232 }, over = {255, 100, 100} -- color on click }, lineColor = { 100, 100, 100 }, params = { cod = data[i].codcli, rsoc = data[i].ragsoc, inds = data[i].indiri, cit = data[i].citta } }

First of all accessing “private” values inside the tableView structure isn’t recommended. We could change any thing that starts with _ at any point.

Personally I don’t depend on the constructor. If I want a certain color background, I’ll drop my own display.newRect() add it to the row as a member variable so it can be accessed anywhere you can access the row and change the color of the background as I need it.

You can also download the code from the widget library from our GitHub account and modify it to your needs.

Rob

First of all accessing “private” values inside the tableView structure isn’t recommended. We could change any thing that starts with _ at any point.

Personally I don’t depend on the constructor. If I want a certain color background, I’ll drop my own display.newRect() add it to the row as a member variable so it can be accessed anywhere you can access the row and change the color of the background as I need it.

You can also download the code from the widget library from our GitHub account and modify it to your needs.

Rob