Android Question Raise an event on a value ScrollView change

gilsonmv

Member
Hello everyone,
This is simplification of "Time Set via Scrollview B4A", post by Björn Roth on 03/10/2012.
The display is updating all the time.
Is it possible to update the display only when ScrollView Position change?
Thanks in advance

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: TimeSet
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals

End Sub

Sub Globals
    Dim Timer2 As Timer
    Dim Panel1(3) As Panel
    Dim ScrollView1 As ScrollView
    Dim pp1 As Int   'ScrollView Positions
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
       Timer2.Initialize("Timer2", 700) 'Display update period

    Activity.LoadLayout("main")
    For ii = 0 To 2
        If ii=0 Then
            SetupScrollViews(ScrollView1,ii,256)
        End If
Next
pp1=Rnd(0,12)*55
End Sub

Sub SetupScrollViews(scv As ScrollView, ii As Int, z As Int)
    Panel1(ii)= scv.Panel
    For i = -2 To z
        Dim Label1 As Label
        Label1.Initialize("")
        Label1.TextSize=24
        Label1.Gravity=Gravity.CENTER
        If i>-1 And i<(z-1) Then Label1.Text=NumberFormat( i,2,0)
        Panel1(ii).AddView(Label1,3,(i+2)*55,96,58)
    Next      
    Panel1(ii).Height=55*i+111
End Sub

Sub ScrollView1_ScrollChanged(Position As Int)
pp1=Position
Timer2.Enabled = True
End Sub

Sub Timer2_Tick
    vv1=Round(pp1/55)
    Activity.Title=vv1 'Show Display
End Sub
 

gilsonmv

Member
Thank you very much for the tip of the xCustomListView, but the application is finished and it has a lot of ScrollViews.
Is it possible to update the display only when the position of any one ScrollView changes?
 
Upvote 0
Top