#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim recycler As Amir_RecyclerView
End Sub
Sub Activity_Create(FirstTime As Boolean)
recycler.Initializer("Amir").ListView.Horizontal.Build
Activity.AddView(recycler,0,0,100%x,100%y)
recycler.ScrollingTouchSlop=recycler.TOUCH_SLOP_PAGING
recycler.LinearSnapHelper
recycler.Adapter=recycler.DefaultAdapter
Dim b As Button
b.Initialize("b")
b.Color=Colors.red
Activity.AddView(b,0,100dip,300dip,100dip)
recycler.ScrollToPosition(2)
End Sub
Sub b_Click
recycler.SmoothScrollToPosition(1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Amir_onCreateViewHolder (Parent As Panel,ViewType As Int)
Dim panel As Panel
panel.Initialize("")
Parent.AddView(panel,0,0,Parent.Width,50dip)
Dim label As Label
label.Initialize("")
panel.AddView(label,0,0,panel.Width,panel.Height)
End Sub
Sub Amir_onBindViewHolder (Parent As Panel,Position As Int)
Dim panel As Panel=Parent.GetView(0)
Dim label As Label=panel.GetView(0)
label.Text="Item " & Position
label.Color=Colors.black
Parent.Width=100%x
Parent.Height=70dip
End Sub
Sub Amir_onScrollStateChanged (NewState As Int)
If NewState = 0 Then
Dim p As Panel=recycler.Utils.ViewIndexToItemObject(recycler,0)
Dim p2 As Panel=p.GetView(0)
Dim l As Label=p2.GetView(0)
Log(l.text)
End If
End Sub
Sub Amir_GetItemCount As Int
Return 200
End Sub