0
我正在關注J.A.的視頻。 Whyte在他的教程中,在我看來,是一款夢幻般的Corona SDK商業應用教程。我在屏幕上輸入代碼時輸入了代碼。我添加了一些故障排除代碼,但在顯示網格時,我無法獲取數據以填充屏幕。我還爲我的手機創建了一個構建,並在之前的sdk build 2013.12.7上運行它。這是代碼。你可以註釋掉對ping的引用。使用display.newRetinaText與Widget顯示錶格數據時出現問題
local widget = require("widget")
local top = display.statusBarHeight
local listRecs ={}
local list = nil
local nameData = {"Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas", "Jackson", "White", "Harris"}
local function setup()
local bg = display.newRect(0,top, display.contentWidth, display.contentHeight - top)
bg:setFillColor(0,155,73)
list = widget.newTableView {top = top +10, height = 450 }
maskFile = "mask.png"
end
local function loadData()
for x =1 , #nameData do
listRecs[x] = {}
listRecs[x].name = nameData[x]
listRecs[x].age = math.random(18,35)
listRecs[x].showDel = false
print(listRecs[x].name.." "..listRecs[x].age)
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
print("the index value is: "..idx)
row.textObj = display.newRetinaText(listRecs[idx].name, 0, 0, "Helvetica", 16)
row.textObj:setTextColor(color)
row.textObj:setReferencePoint(display.CenterLeftReferencePoint)
row.textObj.x = 20
row.textObj.y = rowGroup.contentHeight*0.35
row.textObj2 = display.newRetinaText(listRecs[idx].age, 0, 0, "Helvetica", 16)
row.textObj2:setTextColor(color)
row.textObj2:setReferencePoint(display.CenterLeftReferencePoint)
row.textObj2.x = 20
row.textObj2.y = rowGroup.contentHeight*0.65
rowGroup:insert(row.textObj)
rowGroup:insert(row.textObj2)
end -- onRowRender
local function rowListener(event)
end -- row Listener
for x = 1, #listRecs do
list:insertRow{
onRender = onRowRender,
listner = rowListener
}
end
end -- showRecords
setup()
loadData()
showRecords()