Android Question Expandable list question #2

trepdas

Active Member
Licensed User
Hi
I am trying to dive into the code shown in the tutorial :


B4X:
#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
    Private clv1 As CustomListView
    Private lblTitle As B4XView
    Private pnlTitle As B4XView
    Private pnlExpanded As B4XView
    Private xui As XUI
    Private expandable As CLVExpandable
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    expandable.Initialize(clv1)
    For i = 1 To 20
        Dim p As B4XView = CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i, Rnd(100dip, 300dip) + 60dip)
        clv1.Add(p, expandable.CreateValue(p, "some value"))
       
    Next
End Sub

Sub CreateItem(clr As Int, Title As String, ExpandedHeight As Int) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, ExpandedHeight)
    p.LoadLayout("Item")
    p.SetLayoutAnimated(0, 0, 0, p.Width, p.GetView(0).Height) 'resize it to the collapsed height
    lblTitle.Text = Title
    pnlTitle.Color = clr
    pnlExpanded.Color = ShadeColor(clr)
    Return p
End Sub

Sub ShadeColor(clr As Int) As Int
    Dim argb() As Int = GetARGB(clr)
    Dim factor As Float = 0.75
    Return xui.Color_RGB(argb(1) * factor, argb(2) * factor, argb(3) * factor)
End Sub

Sub GetARGB(Color As Int) As Int()
    Private res(4) As Int
    res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
    res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
    res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
    res(3) = Bit.And(Color, 0xff)
    Return res
End Sub


Sub clv1_ItemClick (Index As Int, Value As Object)
    expandable.ToggleItem(Index)
    Log ("item "&Index&" clicked")
   
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

on line 33 'some value' is created to expandable list.
how do I display it when I open to expand ?

also,can you add an example on the click event button on the expandable list?
(log ("Clicked # "& index))

thxxxx
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top