#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
Private xui As XUI
End Sub
Sub Globals
Private CustomListViewIndex_1 As Int = -1
Private CustomListView1 As CustomListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
For i = 0 To 7
Private p As Panel
p.Initialize("")
p.SetLayoutAnimated(0, 0, 0, CustomListView1.AsView.Width, 60dip)
p.LoadLayout("Item")
Private cd As ColorDrawable
cd.Initialize(Rnd(0xFF000000, -1), 15dip)
p.GetView(0).As(Button).Background = cd
p.GetView(0).As(Button).Text = i
CustomListView1.Add(p, "")
Next
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Log(KeyCode)
If KeyCode = KeyCodes.KEYCODE_DPAD_UP Then
If CustomListViewIndex_1 > 0 Then
CustomListViewIndex_1 = CustomListViewIndex_1 - 1
For i = 0 To CustomListView1.Size - 1
CustomListView1.GetPanel(i).GetView(1).Visible = False
CustomListView1.GetPanel(i).GetView(2).Visible = False
Next
CustomListView1.ScrollToItem(CustomListViewIndex_1)
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(0).RequestFocus
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(1).Visible = True
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(2).Visible = True
End If
Return True
Else If KeyCode = KeyCodes.KEYCODE_DPAD_DOWN Then
If CustomListViewIndex_1 < CustomListView1.Size - 1 Then
CustomListViewIndex_1 = CustomListViewIndex_1 + 1
For i = 0 To CustomListView1.Size - 1
CustomListView1.GetPanel(i).GetView(1).Visible = False
CustomListView1.GetPanel(i).GetView(2).Visible = False
Next
CustomListView1.ScrollToItem(CustomListViewIndex_1)
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(0).RequestFocus
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(1).Visible = True
CustomListView1.GetPanel(CustomListViewIndex_1).GetView(2).Visible = True
End If
Return True
End If
Return False
End Sub