Issue Coloring a Listview Label

Roger Garstang

Well-Known Member
Licensed User
Longtime User
I have a Listview where, depending on the data I'm showing, is supposed to draw with different colors, but draws with the wrong colors.

I clear it (itemList.Clear) then set the color with:

itemList.TwoLinesLayout.Label.TextColor = Colors.Red

or

itemList.TwoLinesLayout.Label.TextColor = Colors.Blue

Then I add my items to it.

This does not always give me accurate results though. Sometimes the whole list stays the previous color and both types of data show Red or both will show Blue when I toggle...or even weirder they will all be the correct color except 1-2 of them the wrong color (Often the first item and one of the last ones that is usually not visible until I scroll it up).

If I add a DoEvents after the color change it improves it slightly, but still has wrong colors. I even tried invalidating it after adding all my items and it still colors wrong. How it draws two different colors is confusing too since I assume these colors are global to the Listview, so they should all be the same color.
 

walterf25

Expert
Licensed User
Longtime User
ListView Colors

You need to do something like this

B4X:
Dim Label1 As Label
Label1 = ListView1.TwoLinesLayout.SecondLabel
Label1.TextSize = 20
Label1.TextColor = Colors.Green

Hope this is what you're looking for!

Cheers,
Walter
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Nope, all that did was dimension a 2nd Label to point to the one that already exists in the listview. It still draws wrong when using a variable to hold it. I was hoping maybe the text size change would give it a kick, but it didn't. I even tried itemList.TwoLinesLayout.Label.Invalidate before the DoEvents, but it still draws 1-2 of them in the wrong color. I think I do remember something in another thread about Label Colors not sticking. I'm trying to find it and will see what the results were there...maybe it was similar enough to work here.
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Frankly, I do not think there are people who swim through a 300 View
Such a view, I would divide or create a button More
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Perhaps this is an option?
 

Attachments

  • optie.jpg
    optie.jpg
    15.9 KB · Views: 675
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
I kind of like that...looks like my email app I use actually where each item is colored different for different accounts. I may try that with a Two Lines and Bitmap Listview. I should be able to resize and shift things and make different colored images for the lines. Then I can switch colors without issue since they are images. May even just draw in the bitmap then I can use a gradient, etc and build it on the fly.
 
Upvote 0
Top