Ok here is my problem scrollview works but does not scroll or display all of my content…it only displays 1 of 4 pages of content, here is my code…
display.setStatusBar( display.HiddenStatusBar )
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
require “sqlite3”
local widget = require( “widget-v1” )
local function scrollListener( event )
local phase = event.phase
if ( phase == “began” ) then print( “Scroll view was touched” )
elseif ( phase == “moved” ) then print( “Scroll view was moved” )
elseif ( phase == “ended” ) then print( “Scroll view was released” )
end
– In the event a scroll limit is reached…
if ( event.limitReached ) then
if ( event.direction == “up” ) then print( “Reached top limit” )
elseif ( event.direction == “down” ) then print( “Reached bottom limit” )
elseif ( event.direction == “left” ) then print( “Reached left limit” )
elseif ( event.direction == “right” ) then print( “Reached right limit” )
end
end
return true
end
– Create image sheet for custom scroll bar
local scrollBarOpt = {
width = 30,
height = 20,
numFrames = 3,
sheetContentWidth = 20,
sheetContentHeight = 60
}
local scrollBarSheet = graphics.newImageSheet( “scrollBar.png”, scrollBarOpt )
–Creating scroll view
local scrollView = widget.newScrollView
{
top = 0,
left = 50,
width = display.contentWidth,
height = display.contentHeight,
scrollWidth = display.contentWidth*2,
scrollHeight = display.contentHeight*2,
horizontalScrollDisabled = false,
verticalScrollDisabled = false,
backgroundColor = {255,255,255,255} – r,g,b, alpha
}
– Let the following be the image path from DB
local path = system.pathForFile(“mydatabase2.sqlite”, system.ResourceDirectory)
db = sqlite3.open( path )
----Next, I setup some code to handle an applicationExit event, so that the database will be properly closed should the user hit the home button.
—I’ve included a couple of print statements to show the current version and path being used to help with troubleshooting:
print ("version "…sqlite3.version())
print ("db path "…path)
—Next, I use a select statement, limiting the rows found to 10, and display the content of those rows to my device:
local sql = “SELECT category FROM projects WHERE id = 1”
for row in db:nrows(sql) do
local text = row.category
–Insert the image object into the scroll view
local t = display.newText(text,20, 20, 20,20, “Helvetica”, 12)
t:setReferencePoint( display.BottomRightReferencePoint )
t.x = display.contentWidth+50
t.y = display.contentHeight
scrollView:insert( t )
t:setTextColor(0,0,0)
end
–and finally, I setup the system event listener for that close event that I handled earlier.
– — system listener for applicationExit
function scene:createScene ( event )
local group = self.view
end
function scene:enterScene( event )
end
function scene:exitScene( event )
local group = self.view
scrollView:removeSelf()
end
function scene:destroyScene( event )
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
any help would be appreciated…