Private VP As AHViewPager
Private PC As AHPageContainer
Private TabLayout As DSTabLayout
Dim data As List
Private JSListView1 As JSListView
Private clvImage As ImageView
Private clvLabel As Label
Private clvSub As Label
Private clvType As Label
Private clvApply As Button
Private clvLike As Button
Private clvComment As Button
Sub Activity_Create(FirstTime As Boolean)
'Initialize a PageContainer Object with 3 pages. Each page contains a panel with different color
PC.Initialize
'Create 4 tabs
For i = 0 To 3
Dim js As JSONParser
js.Initialize(File.ReadString(File.DirAssets, "MOCK_DATA.json"))
Dim data As List = js.NextArray
' Create gradient divider
Dim cd As GradientDrawable
Dim c() As Int = Array As Int(Colors.rgb(252, 237, 242), 0xFFE91E63, Colors.rgb(252, 237, 242))
cd.Initialize("TR_BL", c)
JSListView1.Divider = cd
JSListView1.DividerHeight = 3dip
JSListView1.DataSource = data
'JSListView1.FastScrollEnabled = True
'Don't add a title here
PC.AddPage(JSListView1,"")
Next
'Set the PageContainer for the ViewPager
VP.PageContainer = PC
'Set colors. The indicator color defaults to "colorAccent"
Dim ac As AppCompat
TabLayout.Color = ac.GetThemeAttribute("colorPrimary")
'TabLayout.TabIndicatorColor = Colors.White
'Connect the TabLayout with the Viewpager.
'This will create the tabs and will keep tabs and pages
'in sync and creates a nice indicator animation.
TabLayout.SetViewPager(VP)
TabLayout.SetTabTextColors(Colors.ARGB(150,255,255,255),Colors.White)
TabLayout.SetTabText(0,"vvvv")
TabLayout.SetTabText(1,"cccc")
TabLayout.SetTabText(2,"xxxx")
TabLayout.SetTabText(3,"zzzz")
End sub
Sub JSListView1_OnGetView(position As Int, itemLayout As ItemViewLayout, forViewUpdate As Boolean)
Log($"JSListView1_OnGetView @ Position: ${position}"$)
Dim iv As ItemViewLayout = itemLayout
Dim p As Panel
p.Initialize("")
If forViewUpdate = False Then
p.LoadLayout("customlistview")
iv.Container = p
clvLabel.Tag = 1
clvSub.Tag = 2
clvType.Tag = 3
clvImage.Tag = 4
clvApply.Tag = 5
clvComment.Tag = 6
clvLike.Tag = 7
iv.Height = clvImage.Top + clvImage.Height + 200dip
iv.Width = 100%x
End If
Dim mapper As Map = data.Get(position)
clvLabel = iv.findViewWithTag(1)
clvSub = iv.findViewWithTag(2)
clvType = iv.findViewWithTag(3)
clvImage = iv.findViewWithTag(4)
clvApply = iv.findViewWithTag(5)
clvComment = iv.findViewWithTag(6)
clvLike = iv.findViewWithTag(7)
clvLabel.Text = $"(${mapper.Get("id")}) ${mapper.Get("fullname")} - ${mapper.Get("job_title")}"$
clvType.Text = mapper.Get("company")
clvSub.Text = mapper.Get("slogan")
p = iv.Container
If position Mod 2 = 0 Then
p.Color = Colors.Transparent
Else
p.Color = Colors.ARGB(20, 100, 100, 100)
End If
End Sub
Sub JSListView1_OnItemClick(view As ItemViewLayout, position As Int)
ToastMessageShow($"JSListView1_OnItemClick @ position: ${position}"$, False)
End Sub
Sub JSListView1_OnItemLongClick(view As ItemViewLayout, position As Int)
ToastMessageShow($"JSListView1_OnItemLongClick @ position: ${position}"$, False)
End Sub