B4J Tutorial [ABMaterial] Infinite scrolling pages with 1.07

alwaysbusy

Expert
Licensed User
A new feature in v1.07 will be Infinite Scrolling Pages (like twitter, facebook, etc). It's going to be super simple to make :)

Demo video:

The code:
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    ...
    LoadNewCard
End Sub

Sub Page_NextContent(TriggerComponent As String)
    LoadNewCard
End Sub

Sub LoadNewCard()
    Dim pagecont As ABMContainer = page.Component("cont")

    ' build the card
    Dim tmpCard As ABMCard
    tmpCardId = tmpCardId + 1
    DateTime.TimeFormat = "HH:mm:ss"
    tmpCard.InitializeAsCard(page, "card" & tmpCardId, DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.now), "This is a new card from an infinite page", ABM.CARD_LARGE, "whitetitle")
    Dim picNr As Int = Rnd(1,96)
    tmpCard.Image = "../images2/" & picNr & ".jpg"
    tmpCard.AddAction("BUTTON 1")   

    ' add the card and refresh
    pagecont.Cell(15,1).AddComponent(tmpCard)
    pagecont.cell(15,1).Refresh

    ' set this card as the new trigger, when 200 pixels from the bottom
    page.RaiseNextContentOnComponent(tmpCard,200)
End Sub
 
Last edited:

somed3v3loper

Well-Known Member
Licensed User
And this ?
B4X:
Sub Page_NextContent(TriggerComponent As String)
    publictrigger = TriggerComponent
    'add show more item (button or another view )
End Sub

sub showmore_Click
    ' retrieve new items starting with publictrigger
end sub
 

alwaysbusy

Expert
Licensed User
you can get any component in the same way as before:

dim myCard as ABMCard = pagecont.component("cardname")

so in your case you would make a loop, starting from publicTrigger to the las one you added.
 
Top