Android Question Is it possible to change the background on a individual listitem

mscientist33

Active Member
Licensed User
I have a combobox that is set to a list. I have been able to change the color of the text and even the background of the text but I need the background to go all across the item in the combobox. All the combobox list items will not have the same backcolor.
 

TILogistic

Expert
Licensed User
Longtime User
?? B4XComboBox
1639183370063.png
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I need the background to go all across the item in the combobox. All the combobox list items will not have the same backcolor.
1. One way to do it is: Use CSBuilder to build your items with the colors you want and use Typeface(Typeface.MONOSPACE) for the text and pad the strings with spaces so all lengths are the same. You can use a sub like this, (which can be refined by the way) to pad the item strings.
B4X:
 Sub Repeat(s As String, x As Int) As String  
'for instance, if string is str= "Bird" and you want the total fixed length to be 20, you run: Repeat(str, 20) as the string in your CSBuilder
    Dim y As Int = x-s.Length
    For i =0 To y - 1
        s = s & " "
    Next
    Return s
End Sub
I thought you are getting help from post#2. That is why I held off. You will be able to get a look like the attached screenshot when you scroll down the B4XComboBox. If you need further help, come back.
 

Attachments

  • B4XComboBoxWithCSBuilder and fixed width.png
    B4XComboBoxWithCSBuilder and fixed width.png
    23.6 KB · Views: 257
Upvote 0
Top