iOS Question [B4X] Get the label from an TextItem of a CustomListView

Mike1970

Well-Known Member
Licensed User
Hi everyone, it is possibile to get a reference of the label used for the "TextItem" of a CustomListView?

i wish to change the backgroud color of the label, text size, round the corners etc..

I know that there is the .DesignerLabel method, but if i try to change color it does not work

Thanks in advance
 

mangojack

Well-Known Member
Licensed User
Longtime User
Hi everyone, it is possibile to get a reference of the label used for the "TextItem" of a CustomListView?

I do not play with B4i and have not a clue if this answers your question , but ....

in B4A ...
B4X:
Dim pnl As B4XView = clv1.GetPanel(Index)
pnl.getview(0).Text = "abc"    'index(0) is the panel label populated using  .AddTextItem method


Cannot comment on setting other Label properties in B4i

 
Last edited:
Upvote 0

gmoriwaki

Member
Licensed User
B4X:
'Lets load the screen for the item layout
Pnl.LoadLayout("layout1")

label1.Text = "This is the label text "
label1.color = Colors.Blue
label1.TextColor = Colors.Black

Once the layout is loaded, you will have access to the views/controls in the layout.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
B4X:
'Lets load the screen for the item layout
Pnl.LoadLayout("layout1")

label1.Text = "This is the label text "
label1.color = Colors.Blue
label1.TextColor = Colors.Black

Once the layout is loaded, you will have access to the views/controls in the layout.
No I don’t load any layout , I use this

Clv.AddTextItem(“hello”,”hello”)
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
I do not play with B4i and have not a clue if this answers your question , but ....

in B4A ...
B4X:
Dim pnl As B4XView = clv1.GetPanel(Index)
pnl.getview(0).Text = "abc"    'index(0) is the panel label populated using  .AddTextItem method


Cannot comment on setting other Label properties in B4i

So you are saying to cycle all the element and do it one by one, right?

My intention was to customize the label used in the library it self. Because the element are added wit

clv.AddTextItem(“hello”,1)

so it mean that there is a label inside the library.
Infact there is a method “.DesignerLabel” that somethings like Font, textColor let you to change.

but for example a need to change the background color of the label, but it does not work :(
 
Upvote 0

gmoriwaki

Member
Licensed User
B4X:
Dim item As CLVItem = clv1.GetRawListItem(Index)

'Every custom list view has a panel within    
Dim p As Panel = item.Panel.GetView(0)

''This is the label item 
Dim lbl As Label = p.GetView(0)

'Now you can access those elements
lbl.Text = "Change the text of the label"

'Change the label text color
lbl.TextColor = Colors.Black

This is still new to me, but this is how I do it.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
So you are saying to cycle all the element and do it one by one, right?


There are two ways you can do this ... Loop thru the CLV once you have filled it ...
B4X:
For i = 0 to clv1.Size -1
Dim p As B4XView = clv1.GetPanel(i)
p.GetView(0).Color = '.........  your text Label


Or Immediately after you have called .AddTextItem(....).
B4X:
clv1.AddTextItem("Hello", "")
Dim p As B4XView = clv1.GetPanel(clv1.Size -1)
p.GetView(0).Color = '............. your text Label


*** But I do Not know how to change Label Properties in B4i (is it any different ?)

so it mean that there is a label inside the library.

When you call clv.AddTextItem() , a Row/Panel/Pane is added and the Text is displayed in a Label (index 0).
 
Last edited:
Upvote 0

Mike1970

Well-Known Member
Licensed User
Or Immediately after you have called .AddTextItem(....).
B4X:
clv1.AddTextItem("Hello", "")
Dim p As B4XView = clv1.GetPanel(clv1.Size -1)
p.GetView(0).Color = '............. your text Label

Cool <3 thanks!! i think this is doing the job! thanks :D
 
Upvote 0
Top