【发布时间】:2016-02-26 09:37:28
【问题描述】:
我正在观看有关 Corona Table View 的视频教程,输入了与教程中相同的代码,但未能在行中显示数据,但它显示了教程。如果我输入错误,有人可以检查我的代码吗? tableView这是视频教程: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()
【问题讨论】:
-
我遇到了这个问题,发现我的背景颜色和文本颜色默认为白色。
-
更改文本或背景颜色。
-
但是列表视图默认为白色,我已经将文本颜色设置为0,这意味着黑色,对吧?
标签: android uitableview lua coronasdk mobile-application