Android Question B4XSearchTemplate - Is it possible to change the text color of each item?

Daica

Active Member
Licensed User
I am using B4XSearchTemplate and I would like to change the text color of the items.
Would I use B4XSearchTemplate.GetPanel?

Is there an example somewhere on the forum (I've searched) because Im looking through all the functions of B4XSearchTemplate but cannot see how I can change the text color.
I don't want to change ALL of the item text color, just a few particular ones.
 

Mahares

Expert
Licensed User
Longtime User
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Well this template has a srch.CustomListView1
After you set the items, you maybe able to change the text colors of particular CLV items before showing the dialog.

Give it a try. Let us know.
 
Upvote 0

Daica

Active Member
Licensed User
Not with B4XSearchTemplate. You can do it with B4XListTemplate.

Do you have some example code to change the textcolor? I don't want to change all of the text color through the "DefaultTextColor", only for some of the items.
I've search the forum but nothing came up.

Based on what you said here about using csbuilder, I tried it but the textcolor is not affect.

B4X:
Dim cs As CSBuilder
cs.Initialize.Append("Test Text").Color(Colors.Red).PopAll
MyB4XListTemplate.Options.Add(cs)
 
Last edited:
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Are you using a B4XSearchTemplate? Then as above #2 and #4: NO.
The reason is that the list is changed internally by the search process, and you don't have access to that process.
 
Upvote 0

Daica

Active Member
Licensed User
Are you using a B4XSearchTemplate? Then as above #2 and #4: NO.
The reason is that the list is changed internally by the search process, and you don't have access to that process.

I am now using the B4XListTemplate as Erel suggested. I dont know how to change the text color. I posted an example code above
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
You have to put the color tag before the text

B4X:
Dim cs As CSBuilder
Label1.Text = cs.Initialize.Color(Colors.Red).Append("Hello World!").PopAll
 
Upvote 1
Solution

Daica

Active Member
Licensed User
You have to put the color tag before the text

B4X:
Dim cs As CSBuilder
Label1.Text = cs.Initialize.Color(Colors.Red).Append("Hello World!").PopAll

Well, that did it...
Thank you. I will just use B4XListTemplate for now if I need to customize the item text color and SearchTemplate for long list that needs searching
 
Upvote 0
Top