Android Question .ScrollPosition does nothing

DIYMicha

Member
Okay, I've got a ScrollView that scrolls manually just like a charm. But when I try to set the .ScrollPosition in runtime, nothing happens. I grinded through all scrollview related posts here, tried "DoEvents", tried "sleep(0)" tried a for next loop... nothing.

B4X:
Sub btnPrefs_Click
    lblPflanzenName.Text="UP! "&hoscPictureSlider.ScrollPosition
    Sleep(0)
    hoscPictureSlider.ScrollPosition=hoscPictureSlider.ScrollPosition+100dip
End Sub

Sub btnInfo1_Click
    lblPflanzenName.Text="DOWN! "&hoscPictureSlider.ScrollPosition
    Sleep(0)
    hoscPictureSlider.ScrollPosition=hoscPictureSlider.ScrollPosition-100dip  
End Sub

Sub hoscPictureSlider_ScrollChanged(Position As Int)
    lblPflanzenName.Text=Position & " - " & hoscPictureSlider.ScrollPosition
End Sub

Now, with that code, clicking on the buttons return always zero when "text = ScrollView.ScrollPosition".
in ScrollChanged the value Position increments/decrements perfectly when I drag the ScrollView manually. But ScrollPosition stays zero.
How is this possible?
Thanks.
 

DIYMicha

Member
Okay, when I simply load this example, and apply my changes like so:

B4X:
Sub btn_Click
    Dim v As View
    v = Sender 'this way we can handle both buttons from the same sub.
    ScrollView1.ScrollPosition = ScrollView1.ScrollPosition + v.Tag 'v.tag will be -200 or 200.
    Label1.Text=ScrollView1.ScrollPosition
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub ScrollView1_ScrollChanged(Position As Int)
    Label1.Text=Position&" - "& ScrollView1.ScrollPosition
End Sub

without changing anything else, it works. Position & scrollView.scrollposition show the same numbers. Which trigger did I miss to set?
 
Upvote 0
Top