Hello everyone, I just found another problem with the tableview.
Recently I had problems with “deleteRow” in this thread: http://forums.coronalabs.com/topic/34014-problem-deleting-rows-in-tableview/. Corona has confirmed to me that this is a bug and they will try to solve it.
Currently working with build 2013.1094 and although I think this is a bug, I expose my problem to know your opinion.
this is my little program code:
[lua]
– Import the widget library
local widget = require( “widget” )
local list
local addButton
local listRows = {} – my new table
– Handle row rendering
local function onRowRender( event )
local row = event.row
local rowTitle = display.newText( row, "List item " … row.index, 0, 0, native.systemFontBold, 16 )
rowTitle.x = row.x - ( row.contentWidth * 0.5 ) + ( rowTitle.contentWidth * 0.5 )
rowTitle.y = row.contentHeight * 0.5
rowTitle:setTextColor( 0, 0, 0 )
table.insert(listRows, row.index) – Add the row.index to my table
end
– Handle row touch events
local function onRowTouch( event )
local phase = event.phase
local row = event.row
local found
if “release” == phase then
found = table.indexOf(listRows, row.index)
table.remove(listRows, found) – Delete the row from my table
list:deleteRow(row.index)
end
end
– Create a tableView
list = widget.newTableView
{
top = 38,
width = 320,
height = 448,
maskFile = “mask-320x448.png”,
onRowRender = onRowRender,
onRowTouch = onRowTouch,
}
– insert rows into list (tableView widget)
for i = 1, 3 do
list:insertRow{
height = 72,
}
end
local function addRow(event)
if event.phase == “ended” then
list:insertRow{
height = 72,
}
end
end
– Create a button for insert new rows
addButton = widget.newButton{
left = 25,
top = 5,
width = 100,
height = 30,
label = “Add”,
onEvent = addRow,
}
[/lua]
The steps to reproduce the problem are:
-
I scroll up until 3 rows hidden there at the beginning and when I release my finger reappear the three firsts rows.
-
I press the button to add a new row and then instead of inserting the row # 4, it inserted row 6, 7 or 8 and the draw on the second row.
I hope your help
thanks and regards
good weekend