I think that I’ve got my code almost figured out, but my simulator screen remains blank. Although, it responds as if the data is there (scrolls a long way).
I did a print test near the bottom of my code and the database does appear on the output window.
Here are the last few lines of my code:
print ( listRecs[x].rowid, listRecs[x].date, listRecs[x].title ) end end -- showRecords db = setUpDatabase("mydatabase.sqlite") setupInterface() loadData() showRecords()
And, like I said, that print statement spits out the correct data. I have wondered if it’s a color problem, but I don’t know enough, I guess. I think this is the relevant code for the display problem. If I should look somewhere else, please let me know.
local function showRecords() local function onRowRender( event ) local phase = event.phase local row = event.row local rowGroup = event.view local idx = event.index --add event.index to work with widgets 2.0 local color = {0,0,0} --widgets 2.0 db:insertRow{ -- changed list to db rowHeight=rowHeight, isCategory=isCategory, --rowColor=rowColor, lineColor=lineColor, } -- title to display row.textObj = display.newRetinaText( listRecs[idx].title, 0, 0, "Helvetica", 16 ) row.textObj:setTextColor( color ) row.textObj:setReferencePoint( display.CenterLeftReferencePoint ) row.textObj.x = 20 row.textObj.y = rowGroup.contentHeight \* 0.35 -- add date to display row.textObj2 = display.newRetinaText( listRecs[idx].date, 0, 0, "Helvetica", 12 ) row.textObj2:setTextColor( color ) row.textObj2:setReferencePoint( display.CenterLeftReferencePoint ) row.textObj2.x = 20 row.textObj2.y = rowGroup.contentHeight \* 0.65 local function delRow( event ) print("Delete hit: " .. tostring(event.target.id)) local dbid = listRecs[event.target.id].id list:deleteRow(event.target.id) --remove from list widget table.remove(listRecs, event.target.id) --remove from table display.remove( detailGrp ) -- delete from database function deletData(id) local sql = "delete from News where id = " .. tostring(id) db:exec(sql) end deleteData(dbid) -- end row.delButton = widget.newButton{ -- check with Widgets 2.0 docs id = row.index, top = rowGroup.contentHeight \* 0.2, left = rowGroup.contentWidth - 90, default = "deletebtn.png", width = 64, height = 33, onRelease = delRow } row.delButton.alpha = 0 if listRecs[idx].showDel == true then row.delButton.alpha = 1 end rowGroup:insert(row.delButton) rowGroup:insert(row.textObj) rowGroup:insert(row.textObj2) -- display doesn't work. Refer to Widgets 2.0 documentation end --onRowRender local function rowListener( event ) local background = event.background local row = event.row local phase = event.phase if phase == "press" then print( "Pressed row: " .. row.index ) background:setFillColor( 196, 255, 156, 255 ) elseif phase == "release" or phase == "tap" then print( "Tapped and/or Released row: " .. row.index ) background:setFillColor( 196, 255, 156, 255 ) row.reRender = true -- go to new scene or add details to part of screen showDetails(row.index) elseif phase == "swipeLeft" then print( "Swiped Left row: " .. row.index ) listRecs[row.index].showDel = true row.reRender = true elseif phase == "swipeRight" then print( "Swiped Right row: " .. row.index ) listRecs[row.index].showDel = false display.remove( row.delButton ) end end -- rowListener for x = 1, #listRecs do list:insertRow { onRender = onRowRender, listener = rowListener } print ( listRecs[x].rowid, listRecs[x].date, listRecs[x].title ) end end -- showRecords