Android Question Change Label TextColor by variable

Marco Maria Vilucchi

Active Member
Licensed User
Longtime User
Hi, i need to change TextXolor of a Label and i can take the color from a variable
B4X:
    Dim ColActive As ColorDrawable
    Dim ColInactive As ColorDrawable
    ColActive.Initialize(Colors.black, 10dip)
    ColInactive.Initialize(Colors.LightGray, 10dip)
    Label1.textcolor=ColActive
    Label2.textcolor=ColInactive
    Label3.textcolor=ColInactive
    .....
    Label99.textcolor=ColInactive
    Label100.textcolor=ColActive
I have an errore on Label1.textcolor=ColActive and Label2.textcolor=ColInactive
Someone can help me?
Marco
 

Mahares

Expert
Licensed User
Longtime User
ColorDrawable is for background. You need to use something like this:
B4X:
Dim colActive As Int =Colors.Black
Dim colInactive As Int =Colors.LightGray
Label1.textcolor=ColActive
 Label2.textcolor=ColInactive
 Label3.textcolor=ColInactive
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Or even define as a Constant
B4X:
Private Const colActive As Int = Colors.Black
Private Const colInactive As Int = Colors.LightGray

'you can also define more colors than the built in Colors   
Private Const colActive As Int = Colors.RGB (0,139,139)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…