Ciao ragazzi
Sto (cercando) di utilizzare un esempio di erel di una expanded list con la classe CustomListView
https://www.b4x.com/android/forum/threads/expandable-list-based-on-customlistview.81445/#content
ma non ho ancora capito come devo utilizzarla.Nell'esempio del thread di erel, praticamente quando faccio click sul primo item o secondo item, vedo ripetute le stesse cose.Dovrei aggiungere piu' layout o con uno solo?
Erel dice:
Each item is made of a panel with views. You should create the panel and add it to the CustomListView with clv.Add(...). See the example in the first post.
se serve allego un esempio
Gentilmente potete aiutarmi? grazie
Sto (cercando) di utilizzare un esempio di erel di una expanded list con la classe CustomListView
https://www.b4x.com/android/forum/threads/expandable-list-based-on-customlistview.81445/#content
ma non ho ancora capito come devo utilizzarla.Nell'esempio del thread di erel, praticamente quando faccio click sul primo item o secondo item, vedo ripetute le stesse cose.Dovrei aggiungere piu' layout o con uno solo?
Erel dice:
Each item is made of a panel with views. You should create the panel and add it to the CustomListView with clv.Add(...). See the example in the first post.
se serve allego un esempio
Gentilmente potete aiutarmi? grazie
B4X:
Sub Globals
Private clv1 As CustomListView
Private lblTitle As Label
Private pnlTitle As Panel
Private ExpandedHeight As Int = 240dip
Private CollapsedHeight As Int = 60dip
Private pnlExpanded As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
clv1.Add(CreateItem(Colors.DarkGray, "ITEM #1"), CollapsedHeight, "")
clv1.Add(CreateItem(Colors.DarkGray, "ITEM #2"), CollapsedHeight, "")
End Sub
Sub CreateItem(clr As Int, Title As String) As Panel
Dim p As Panel
p.Initialize("")
Activity.AddView(p, 0, 0, 100%x, ExpandedHeight)
p.LoadLayout("item")
p.RemoveView 'remove from parent
lblTitle.Text = Title
pnlTitle.Color = clr
pnlExpanded.Color = Colors.Gray'ShadeColor(clr)
p.Tag = False 'collapsed
Return p
End Sub
Sub ExpandItem (index As Int)
clv1.ResizeItem(index, ExpandedHeight)
clv1.GetPanel(index).Tag = True
AnimatedArrow(index, 0, 180)
End Sub
Sub AnimatedArrow(index As Int, From As Int, ToDegree As Int)
Dim An As AnimationPlus
pnlTitle = clv1.GetPanel(index).GetView(0) 'pnlTitle is the first item
Dim iv As ImageView = pnlTitle.GetView(1) 'ImageView1 is the second item
An.InitializeRotateCenter("", From , ToDegree, iv)
An.Duration = clv1.AnimationDuration
An.RepeatCount = 0
An.PersistAfter = True
An.Start(iv)
End Sub
Sub CollapseItem(index As Int)
clv1.ResizeItem(index, CollapsedHeight)
clv1.GetPanel(index).Tag = False
AnimatedArrow(index, 180, 0)
End Sub
Sub clv1_ItemClick (Index As Int, Value As Object)
Log(Index)
Log(Value)
Dim p As Panel = clv1.GetPanel(Index)
If p.Tag = True Then
CollapseItem(Index)
Else
ExpandItem(Index)
End If
End Sub
Sub FindExapnded As Int 'ignore
For i = 0 To clv1.GetSize - 1
If clv1.GetPanel(i).Tag = True Then Return i
Next
Return -1
End Sub