listview:2e label color

Cor

Active Member
Licensed User
Longtime User
second label will not change to blue color

B4X:
dim foutView as listView

  foutView.TwoLinesLayout.SecondLabel.Height=100dip
  foutView.TwoLinesLayout.SecondLabel.TextSize=20
  foutView.TwoLinesLayout.SecondLabel.Typeface=Typeface.DEFAULT_BOLD
  foutView.TwoLinesLayout.SecondLabel.color=Colors.Blue

I'am i missing something?
 

susu

Well-Known Member
Licensed User
Longtime User
The right code is:

foutView.TwoLinesLayout.SecondLabel.TextColor=Colors.Blue

But I used to write like this:

Dim YearLabel as Label

YearLabel = ListView1.TwoLinesLayout.SecondLabel
YearLabel.TextColor = Colors.Yellow
YearLabel.TextSize = 20
YearLabel.Gravity = Gravity.CENTER
 
Last edited:
Upvote 0

Cor

Active Member
Licensed User
Longtime User
But how to change the color afterwards to another color

.initialize with or without did not change the color

B4X:
' start color
foutView.TwoLinesLayout.Label.TextColor=Colors.blue

' next color
foutView.Initialize("")
foutView.TwoLinesLayout.Label.TextColor=Colors.red
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
You mean 2 lines layout with 2 colors? You should use:

foutView.TwoLinesLayout.Label.TextColor=Colors.red
foutView.TwoLinesLayout.SecondLabel.TextColor=Colors.blue
 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
I mean during initializing i set the text color to black

Now try to change the color to e.g blue when you click on a button

counts for single ot two lines
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I think you need to re-initialize the list view.
 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
code below does also not change second color to red,

stays the same color which first is initialized

B4X:
foutView.Initialize("")
  label1=foutView.TwoLinesLayout.Label
  'Label1.Height=20dip
  Label1.TextSize=20
  Label1.Typeface=Typeface.DEFAULT_BOLD
  Label1.textColor=Colors.white

  label2=foutView.TwoLinesLayout.secondLabel
  'Label2.Height=20dip
  Label2.TextSize=20
  Label2.Typeface=Typeface.DEFAULT_BOLD
  Label2.textColor=Colors.red
  
  label1.Invalidate
  label2.Invalidate
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Maybe you missed something, my code run well just like this

 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
I think you don't understand me.

Now try to change the yellow color to red e.g. when clicking a menu item

Let me know if you can change it.

If succeed please upload a working sample, so i can learn

grCor
 
Upvote 0

HarleyM

Member
Licensed User
Longtime User
Experiencing similar difficulties and want to get a better understanding of this


My problem is as follows:-

I've got 3 listviews that link to arrays (only 2 of 15 columns are used in the listviews for the two labels). I make listviews visible or invisible based on selections. The problem I'm having is that once the first listview fires up none of the following listviews will work with any label.textcolor other than that from the first. I can preset different text size & label colors ok as long as the textcolor is the same. Is this what you meant by layout affects of the same type?

 
Upvote 0

miga

Member
Licensed User
Longtime User
I do understand Cor. I have same problem.
Want to add few items to listview with different collors. But this doesn't work

B4X:
   ListViewC.SingleLineLayout.Label.TextColor = Colors.RGB (255,0,0)
   ListViewC.AddSingleLine ("item")
   ListViewC.SingleLineLayout.Label.TextColor = Colors.RGB (0,255,0)
   ListViewC.AddSingleLine ("item"))
   ListViewC.SingleLineLayout.Label.TextColor = Colors.RGB (0,0,255)
   ListViewC.AddSingleLine ("item")   
        ListViewC.Invalidate
... well, I wanna use even different fonts, but i cannot go even thru this.
What's wrong?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Unfortunately you can't do it.
As Erel already explained.
ALL labels in SingleLineLayout have the same parameters, and you can't change them afterwards.
When using TwoLinesLayout, all the first labels have the same parameters and all the second labels have also same parameters but these can be different from those for the first labels.

To do what you want to do you should use a ScrollView, with this view you have lot of possibitilies, have a look at ScrollView examples summary. And you have access to all views inside the ScrollView and you can change their parameters individually.

ListViews are interesting for very long lists with the fastscrolling feature.
ScrollViews don't have it, but even with about 100 items they remain usable.

Best regards.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I can confirm that. Only limit is if you design a scrollview with many bitmaps, then the Android OS can interfere since your app is using too much memory. In any case, I have a scrollview which loads 250-300 bitmaps and it works nicely and runs very smooth. I guess it might depend on device as well.

I think that ScrollViews can be useful for even longer lists. Maybe up to 500 - 1000 items.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…