0

I was watching a video tutorial about Corona Table View, typed the same codes as in the tutorial but failed to display the data in the rows, but it displayed ni the tutorial. can someone check my code if I typed something wrong? tableView here's the video tutorial: tutorial

local widget = require ("widget")

local top = display.statusBarHeight
local listRecs = {}
local data = {"Altavas", "Balete", "Banga", "Batan", "Buruanga", "Ibajay", "Kalibo", "Lezo", "Libacao", "Madalag", "Makato", "Malay", "Malinao", "Nabas", "New Washington", "Numancia", "Tangalan" }
local list = nil

local function setup()
        list = widget.newTableView {
            top = top + 10,
            height = 960
    }

end

local function loadData()
    for x = 1, #data do
            listRecs[x] = {}
            listRecs[x].name = data[x]
    end
end

local function showRecords()

    local function onRowRender( event )
        local row = event.row
        local rowGroup = event.view
        local idx = row.index or 0
        local color = 0

        row.textObj = display.newRetinaText( listRecs[idx].name, 0, 0, "Century Gothic", 16 )
        row.textObj:setTextColor(color)
        row.textObj:setReferencePoint( display.CenterLeftReferencePoint )
        row.textObj.x = 0
        row.textObj.y = rowGroup.contentHeight * 0.35

        rowGroup:insert(row.textObj)


    end

    local function rowListener( event )

    end 

    for x = 1, #listRecs do
        list:insertRow {
            onRender = onRowRender,
            listener = rowListener
        }
    end

end


setup()

loadData()

showRecords()

1 Answers1

0

Use: https://docs.coronalabs.com/api/library/display/newText.html instead of display.newRetinaText as well as use

    setFillColor, instead of row.textObj:setTextColor(color).

As well I encourage You to use new way of declaring display.newTExt that means display.newText({text = "", fontSize = X, font = "", x = , y = }) instead of: display.newText(param1,param2,param3)

Dirindon
  • 634
  • 1
  • 5
  • 15