I have more than thousands of line of codes, but i tried to isolate what is relative here.
The logic is:
When the scollView reaches the end, append new images by downloading them first and adding to them information like title and buttons, then appending it to the scollView by
newsScrollView:insert(newsContainer)
[lua] local function newsScrollListener( event ) -- In the event a scroll limit is reached... if ( event.limitReached ) then if ( event.direction == "up" ) then if( tonumber(nextPageNews) \> 0 ) then showNews() end end end return true end -- Called when the scene's view does not exist: function scene:createScene( event ) newsDisplayGroup = self.view newsScrollView = widget.newScrollView{ id = "newsScrollView", left = 0, top = 50 + statusBarPad, width = display.contentWidth, height = display.contentHeight - (50 + statusBarPad) , backgroundColor = { 255, 255, 255 }, -- bgColor =\> backgroundColor scrollWidth = display.contentWidth, scrollHeight = display.contentHeight , --hideBackground = true, friction = 0.98, listener = newsScrollListener, } newsDisplayGroup:insert( newsScrollView ) end function showNews() for key, value in pairs(news) do network.download( imageURL , "GET", (function(event) local newsContainer = display.newContainer( newsBlockWidth, newsBlockWidth ) newsContainer.x = (newsBlockWidth /2) + ( newsBlockWidth \* (newsInRow - rowIndex) ) newsContainer.y = (newsBlockWidth /2) + ( newsYShift \* newsBlockWidth ) --[[Here is preparing each display object that will be contained in the newsContainer , like title ,image ,buttons , etc]] newsContainer:insert(downloadedImage) newsContainer:insert( blackRect ) newsContainer:insert(halfReadSign) newsContainer:insert(fullyReadSign) newsContainer:insert( moreRect ) newsContainer:insert( timeagoRect ) newsContainer:insert( newsCaption ) newsContainer:insert( newsSummary ) newsContainer:insert( moreText ) newsContainer:insert( timeagoString ) newsScrollView:insert(newsContainer) end ) ,params, imageFileName ,system.TemporaryDirectory) end -- end for loop end [/lua]
If more info is needed would be glad to give more.
Edit: [lua][/lua] Tag didn’t seem to work i don’t know why