Sub Process_Globals
Dim svTopIndex, ItemHo As Int
Dim OrientationZuletzt As String
End Sub
Sub Globals
Dim ScrollView1 As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim x, Ho, Br, PosY, ZCount As Int
'Einrichten:
Ho = Activity.Height
Br = Activity.Width
If FirstTime = True Then
If Ho > Br Then OrientationZuletzt = "Landscape" Else OrientationZuletzt = "Portrait"
End If
ItemHo = 30dip
ZCount = 200
Activity.LoadLayout("Layout01")
Activity.Title = "TestScrollViewPos"
ScrollView1.SetLayout(0, 0, Br, Ho)
ScrollView1.Panel.Height = ItemHo * ZCount
For x = 0 To ZCount -1
Dim Label0 As Label
Label0.Initialize("")
Label0.Color = Colors.Black
Label0.Text = "Zeile " & x
ScrollView1.Panel.AddView(Label0, 0, PosY, Br, ItemHo -1dip)
PosY = PosY + ItemHo
Next
End Sub
Sub Activity_Resume
'TopIndex wieder herstellen:
DoEvents
ScrollView1.ScrollPosition = svTopIndex * ItemHo
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Dim Br, Ho As Int
Br = Activity.Width
Ho = Activity.Height
If Ho > Br AND OrientationZuletzt <> "Portrait" OR Ho < Br AND OrientationZuletzt <> "Landscape" Then
Log("Ermitteln")
'Index der ersten sichtbaren Zeile festhalten:
Dim k As Int
k = (ScrollView1.ScrollPosition / ItemHo)
If k * ItemHo < ScrollView1.ScrollPosition Then k = k +1
svTopIndex = k
If Ho > Br Then OrientationZuletzt = "Portrait" Else OrientationZuletzt = "Landscape"
Else
Log("Nicht ermitteln")
End If
End Sub