在新的滚动视图中,将从数据库中显示Corona的文本。

我正在尝试从SQLite数据库中提取数据到Corona newScollView。

我已经在tableView中获取了数据,所以我认为新的scrollView的代码应该几乎相同。

它一直说行为空,但它不是。有什么帮助?

以下是代码:

function scene:create( event )

local sceneGroup = self.view

local function scrollListener( event )

    -- Get reference to the row group
    local row = event.row

    local options_metni =
    {
        parent = row,
        text = row.params.Metni,
        x = 0,
        y = 0,
        font = native.systemFont,
        fontSize = 16
    }

    local metniObject = display.newText(options_metni)
    metniObject:setTextColor(0)
    metniObject.x = display.contentCenterX
end

---------------------
-- CREATE SCROLLVIEW
---------------------
local scrollView = widget.newScrollView
{
    left = 0,
    top = 0,
    width = display.contentWidth,
    height = display.contentHeight / 2,
    topPadding = 200,
    bottomPadding = 50,
    horiontalScrollDisabled = true,
    verticalScrollDisable = false,
    listener = scrollListener,
}
sceneGroup:insert(scrollView)

---------------------
-- GET DATA FROM DB
---------------------
for row in db:nrows("SELECT baslik FROM dua LIMIT 1") do

if row.data == nil then
    print(" NO DATA FOUND ")
end

    local rowParams =
    {
        duaID       = row.dua_id,
        Metni       = row.baslik,
    }
end
end
点赞
用户2524586
用户2524586

你需要将一个对象插入到scrollView中,它的工作方式不同于tableView。尝试在创建显示对象并设置文本为row.baslik的地方使用下面的代码:

for row in db:nrows("SELECT baslik FROM dua LIMIT 1") do
    local text = display.newText( tostring( row.baslik ), 0, 0, native.systemFont, 16 )
    scrollView:insert( text )
end
2015-09-30 02:12:43