Hi
i’m very new to corona
i’ve a code with composer
when i go to a view with Tableview inside and effect slideLeft, button and title slides but Tableview not,
(tableview appear with no effect), when i go out of this view with slideRight … act in the same manner, buttons and title slides and tableview disappear with no effect…
I’m going crazy… any help and suggestion are VERY appreciated , thanks in advance
code below… and video attached
________________________________________________________________________________________
[lua]
local composer = require( “composer” )
local widget = require(“widget”)
local json = require ( “json” )
local sqlite3 = require ( “sqlite3” )
local centerX = display.contentCenterX
local centerY = display.contentCenterY
local screenLeft = display.screenOriginX
local screenWidth = display.contentWidth - screenLeft * 2
local screenRight = screenLeft + screenWidth
local screenTop = display.screenOriginY
local screenHeight = display.contentHeight - screenTop * 2
local screenBottom = screenTop + screenHeight
local screenTopSB = screenTop + display.topStatusBarContentHeight – when status bar is showing
local screenHeightSB = display.contentHeight - screenTopSB
local screenBottomSB = screenTopSB + screenHeightSB
local scene = composer.newScene()
local _W = display.contentWidth
local _H = display.contentHeight
local bottom = screenBottomSB
local top = screenTopSB +20
local listRecs ={}
local list = nil
local function ShowComuneMenu( )
composer.gotoScene( “ShowComuneMenu”,“slideRight”, 800 )
end
function scene:create( event )
local sceneGroup = self.view
–local bg = display.newImage( “images/background.png”, centerX, centerY )
function makeDataIT( dateString )
–datestring yyyy-mm-dd out examp. Sab 21-11-2015
local pattern = “(%d+)%-(%d+)%-(%d+)”
local year, month, day = dateString:match(pattern)
local timestamp = os.time({ year=year, month=month, day=day, hour=00, min=00, sec=00 })
local offset = 0
local days={“Dom”,“Lun”,“Mar”,“Mer”,“Gio”,“Ven”,“Sab”}
local dow=os.date("%w", timestamp) +1;
local giorno_it=days[dow]
local data_it=os.date("%d-%m-%Y", timestamp);
data_it=os.date("%d-%m-%Y", timestamp);
local giorno_data_it=giorno_it …" "…data_it
return giorno_data_it
end
local db
local text
local path = system.pathForFile( “rifiuti.sqlite”, system.DocumentsDirectory )
db = sqlite3.open( path )
local sql = "SELECT * FROM comuni_set limit 1 "
print( sql )
for row in db:nrows(sql) do
text = row.comune
print (text)
end
local title = display.newText( text, 0, 0, native.systemFont, 32 )
title:setFillColor( 0 ) – black
title.x = centerX
title.y = 20
local text1
local nameData = {}
local nameCat = {}
local sql1 = “SELECT * FROM comuni_date where comune=’”… text …"’ ORDER BY data desc"
print( sql1 )
local countx=1
for row in db:nrows(sql1) do
text1 = makeDataIT(row.data)
text2 = row.categoria
nameData[countx]=text1
nameCat[countx]=text2
print (text1)
countx=countx+1
end
–definisce bottone visualizza menu
local btnVisMenu = widget.newButton ( {
x = centerX,
y = screenBottomSB -20,
label="",
width=300, height=36,
defaultFile = “img/MenuComune.png”,
overFile = “img/MenuComuneO.png”,
onRelease=ShowComuneMenu,
} )
--definisce bottone visualizza menu
local function setup()
--local bg = display.newRect(0,top, display.contentWidth, display.contentHeight - top)
--bg:setFillColor(100,155,73)
list = widget.newTableView
{
top = top +100,
height = _H -200,
onRowRender = onRowRender,
onRowTouch = onRowTouch,
}
--maskFile = “mask.png”
end
local function loadData()
for x =1 , #nameData do
listRecs[x] = {}
listRecs[x].name = nameData[x]
listRecs[x].categoria = nameCat[x]
listRecs[x].showDel = false
print(listRecs[x].name…" "…listRecs[x].categoria)
end
end
function onRowRender(event)
local row = event.row
local groupContentHeight = row.contentHeight
local idx = row.index or 0
local textObj = display.newText( row, listRecs[idx].name … " " … listRecs[idx].categoria, 0, 0, native.systemFontBold, 20 )
textObj.x = 20
textObj.anchorX = 0
textObj.y = groupContentHeight * 0.35
textObj:setFillColor( 0, 0, 0 )
end
– onRowRender
local function showRecords()
local function rowListener(event)
end – row Listener
for x = 1, #listRecs do
list:insertRow{}
end
end
– showRecords
–sceneGroup:insert( bg ) --inserisce bg nella scena
sceneGroup:insert( title ) --inserisce titolo nella scena
sceneGroup:insert( btnVisMenu )
setup()
loadData()
showRecords()
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == “will” then
– Called when the scene is still off screen and is about to move on screen
elseif phase == “did” then
– Called when the scene is now on screen
–
– INSERT code here to make the scene come alive
– e.g. start timers, begin animation, play audio, etc.
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if event.phase == “will” then
– Called when the scene is on screen and is about to move off screen
–
– INSERT code here to pause the scene
– e.g. stop timers, stop animation, unload sounds, etc.)
elseif phase == “did” then
– Called when the scene is now off screen
end
end
function scene:destroy( event )
local sceneGroup = self.view
list:removeSelf() --cancella scrolltab
list= nil
– Called prior to the removal of scene’s “view” (sceneGroup)
–
– INSERT code here to cleanup the scene
– e.g. remove display objects, remove touch listeners, save state, etc.
end
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene
[/lua]