2015-09-28 33 views
1

我試圖從SQLite數據庫中將一些數據提取到Corona newScollView。Corona在newScrollView中顯示來自數據庫的文本

我設法從tableView中的數據庫獲取數據,所以我認爲代碼應該幾乎是相同的newScrollView。

它一直說行是空的,但它不是。任何幫助?

下面是代碼:

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 

回答

0

你需要一個對象插入到了滾動,它不喜歡的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 
相關問題