Android Question Change the Background color of Panel used in CustomListView

phukol

Active Member
Licensed User
Longtime User
How to do you change the Background color of Panel used in CustomListView? I have attached the sample screenshot for the program,

i already tried changing the color of the panel to which the customlistview was added, however, its not doing anything. My panel

is pan2 and the customlistview is clvCat1
B4X:
Dim pan2 As Panel
Dim clvCat1 as CustomListView
     
pan2 = CreatePanel("pan2") 
pan2.Color = Colors.White
pan2.AddView(clvCat1.AsView ,0,0,100%x,100%y)
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
If we look at what your code is doing line by line...
B4X:
Dim pan2 As Panel
Dim clvCat1 as CustomListView
The declaration of a Panel and the CustomListView which is fine but if the panel is to be used for several items in the CustomListView then it needs to be a new declaration each time otherwise it's referencing the same object.
B4X:
pan2 = CreatePanel("pan2")
You've not shown this subroutine but I can imagine you are setting the contents of the Panel and the event name.
B4X:
pan2.Color = Colors.White
Setting the Panel background color.
B4X:
pan2.AddView(clvCat1.AsView ,0,0,100%x,100%y)
Now on this line you are adding the CustomListView into the Panel and filling the entire Panel. I suspect that this is not want you were intending? My guess is that you really wanted to add the Panel into the CustomListView and for this I think you need to use AddItem (I'm using my tablet at the moment so unable to check).
 
Upvote 0
Top