Android Question [RESOLVED] Change the background color of the selected item in a xCustomListView

Joacim

Member
Licensed User
Longtime User
I'm trying to change the background color of the selected item in a listview (xCustomListView, to be precise).

I've tried this, but it doesn't work properly.
B4X:
Sub lvwDecks_ItemClick (Position As Int, Value As Object)
    'Restore the color of all items
    For i = 0 To lvwDecks.size - 1
        lvwDecks.getrawlistitem(i).color = Colors.argb(255, 60, 60, 60)
    Next
    'Change the color of the selected item
    lvwDecks.getrawlistitem(Position).color = Colors.argb(255, 126, 180, 250)
End Sub
 

mangojack

Expert
Licensed User
Longtime User
You can change the selection color in the designer.

Capture.PNG



If you want to handle the selection process / color yourself then have a read here ...
 
Upvote 0

Joacim

Member
Licensed User
Longtime User
Thanks for your reply, the Pressed Color only change the background color for a second or so, I want the selected item to stay in that color, just to make it visibly clear what item you have selected.

The other forum post you linked me towards basically uses the same code I'm already using but it doesn't work properly, it changes the color only if I press the item for a longer period.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I forgot to mention , you first want to set the Pressed Color in the Designer to Transparent.
 
Upvote 0

Joacim

Member
Licensed User
Longtime User
Thanks but now the Color never changes, it seems like the Pressed Color is overwriting the code I have in the ItemClick event, even though I've set the Alpha of the Pressed Color to 0 or set it to the predefined Transparent color.
 
Upvote 0
Top