Android Question How can i changes CustomListView TextItem Heigh

Knoppi

Active Member
Licensed User
Longtime User
How can i changes CustomListView TextItem Heigh?

This works but it is animated and slow
B4X:
Dim clv As CustomListView
clv.AddTextItem( "Text", 0)
clv.ResizeItem( clv.Size -1, 30dip)

with this i can change the Label.Height
but not the Panel.Height
B4X:
Dim p As B4XView = clv.GetPanel( clv.Size -1)
p.Height = 30dip  'dont work
p.GetView( 0).Height = 30dip   'works

I need a TextItem with Panel/Label Height of 30dip
How can i solved it?
 

DonManfred

Expert
Licensed User
Longtime User
p.GetView( 0).Height = 30dip 'works
Because the Textitem is placed on a base panel (GetView(0).
The text itself is probably a label on this panel. GetView(1)?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
When you use AddTextItem: the height depends on the text length. the item height adjusts to the full text by default. So in order to achieve a different height, you have to use clv1.ResizeItem:)
B4X:
Sub Button1_Click
    Dim p As B4XView = clv1.GetPanel( clv1.Size -1)
    Log(p.Height)
    clv1.ResizeItem( clv1.Size -1, 30dip)    
    Dim l As B4XView=p.GetView(0)
    l.Textsize=22
    l.SetTextAlignment("TOP", "CENTER")
    Log(l.Text)
    Log(p.Height)
End Sub
 
Upvote 0

Knoppi

Active Member
Licensed User
Longtime User
I solved it with a custom layout.
B4X:
Private Sub addTextItem( Text As String, Value As Object)
    Dim pnl As B4XView = xui.CreatePanel( "")
    pnl.SetLayoutAnimated( 0, 0, 0, clv.GetBase.Width, 30dip)
    pnl.LoadLayout( "TextItem")   'a simple Label
    Dim lbl As B4XView = pnl.GetView( 0)
    lbl.Text = Text
    clv.Add( pnl, Value)
End Sub
I would still be interested in whether there is also a solution with TextItem?
 
Upvote 0
Top