Hi
I have two tableviews. One tableview is the list of items which you can favorite and other is the list of items you’ve favorited. When I favorite one item (row #2 for instance), one item is displayed on the second list, though the content from the row#1 is displayed. It displays rows’ content one after another, not the content for the necessary rows.
My snippets of code:
favorite button function
function onLikeSwitch( event ) likeSwitchPressed.alpha = 1 transition.to( likeSwitchPressed, {time =200, alpha =0} ) if liked[row.index] == false or liked[row.index] == nil then liked[row.index] = true likeSwitchSelect.alpha = 1 data[row.index].fav = true print (row.index,data[row.index].fav) print( "pressed" ) elseif liked[row.index] == true then likeSwitchSelect.alpha = 0 liked[row.index] = false data[row.index].fav = false end end
RowTitle from onrowrender
local rowTitle = display.newText( row, data[row.index].title, 0, 0, "Roboto-Regular", 12 ) rowTitle:setFillColor( .80, .333, 0)
for loop inserting rows
for i = 1, #data do -- Insert a row into the tableView if data[i].fav == true then tableView:insertRow( { isCategory = false, rowHeight = 80, rowColor = { default={ .882, .925, .941}, over={ 1, 0.5, 0, 0.2 } }, lineColor = { .455, .616, .678 } } ) print ("hello",i, data[i].fav, data[i].title) else print (i, data[i].fav, data[i].title) end
I think I should change rowTitle to show not the data[row.index] but something else, but I can’t figure it out.
Thanks!