Android Question CustomListView, need to access a panel after list is created

Shadow&Max

Active Member
Licensed User
Longtime User
Erel's CustonListView list... It's working great and I've got it doing some pretty neat stuff.

I'm producing 3 lists in a tab host... most of them have the text, and a ToggleButton. Those are all working fine.

In two more, I have the text, a small colored panel showing an already chosen color, and a button. When you click the button, you get the color picker, which stores the new color in a multi-dimensional array, and then gets saved in the database.

I want to change the color of the small panel's background, but can't seem to do it. It does it fine when it's being assigned during list creation, and that works. I Dim'd the two panels in the global section so I can access them, but that doesn't work either... The color's being stored correctly, but I can't seem to get that panel to change on the fly. Now, I know it's contained in a panel, but I would assume that since it's been declared globally, I should still be able to access it directly.

This works when they're being created:

B4X:
'Set the Color from the array
If PassedIndex = 5 Then
  pnl1.Color = setlist(5).Color
Else If PassedIndex = 11 Then
  pnl2.Color = setlist(11).Color
End If

For the button click inside the list , which works but doesn't set the panel color (but it does, correctly, enter the proper value in the array):

B4X:
clrP.RGB = setlist(11).Color
tester = clrP.Show("Choose Display Color:","OK","","Cancel",Null)

If tester = -1 Then
      setlist(11).Color = clrP.RGB
      pnl2.Color = clrP.RGB
End If

Why can't I set pnl2.Color like this???
 
Last edited:

ggpanta

Member
Licensed User
Longtime User
You need to set the color on the specific panel thats already added (instantiated) in the listview, try this on the example of erels custom listview, add in a button this clv3.GetPanel(2).Color = Colors.Red it will colour the second panel in clv3. You need to either use the specific panel index or even better add an iterator on the tag property of each object and use that to get the exact panel you need.
 
Upvote 0

Shadow&Max

Active Member
Licensed User
Longtime User
Thanks... I found my error this morning... I initialized the panels in two places, one overwriting the other... working perfectly as intended now. Was just a late night programming slip...

Thanks for the quick response!
 
Upvote 0
Top