Android Question B4XSearchtemplate with different color of each item

Phayao

Active Member
Licensed User
Longtime User
Hello,

I like to have the colorslist example in form of a template dialog - so I thought to assign a color to each list item in the search template. but to no avail, because i am confused about B4XSearchtemplate.Customlistview1 and sv ....
I tried:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    B4XSearchTemplate1.Initialize
    
    Dim List1 As List
    List1.Initialize
    List1.AddAll(Array As String("Value1", "Value2", "Value3", "Value4", "Value5"))
    B4XSearchTemplate1.SetItems(List1)
'---  so far so good....
    B4XSearchTemplate1.CustomListView1.GetPanel(0).Color = Colors.Cyan  
'==> causes error java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

    Log("=== "& B4XSearchTemplate1.CustomListView1.sv.NumberOfViews )  '==> gives 1 !!
    
    B4XDialog1.Initialize(Root)
End Sub

Where am I wrong here ? Obviously the template is more than just a customlistview !?

Any help is very much appreciated,
Chris
 
Top