Android Question [Custom List View] Best Way For change Item Height?

Roberto P.

Well-Known Member
Licensed User
Longtime User
HI to All
I have to dynamically change the height of an element inserted in the Custom ListView.
To start I deleted item and inserted again with modified height.
Is there a better way?
thanks
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi Erel,
It is what I did.

I think it would be better to add the function to change the height of the elements without having to delete and back the item.

thanks
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
I'll explain with an example.
I have to be able to increase \ decrease the height of a single element when I press the button.
 

Attachments

  • picture 1.png
    picture 1.png
    43.8 KB · Views: 610
  • picture 2.png
    picture 2.png
    33.2 KB · Views: 513
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
exact! But with custom listview.

I'll watch the indicated class.

thank you
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You could use a routine like this:
B4X:
Sub ChangeItemPanelHeight(clv As CustomListView, Index As Int, DeltaHeight As Int)
    Private i As Int
    Private pnl1, pnl2 As Panel
    Private sv As ScrollView
    sv = clv.AsView   'gets the CustoListViews' ScrollView
    pnl1 = sv.Panel    'gets the ScrollView.Panel
    pnl2 = pnl1.GetView(Index)   'gets the item Panel with the given Index
    pnl2.Height = pnl2.Height + DeltaHeight   'changes the item Panel height

    For i = Index + 1 To pnl1.NumberOfViews -1   'changes the Top property of all the Panels above the index Panel
        Private pnl As Panel
        pnl = pnl1.GetView(i)
        pnl.Top = pnl.Top + DeltaHeight
    Next

    sv.Panel.Height = sv.Panel.Height + DeltaHeight   'changes the ScrollView.Panel.Height
End Sub
The advantage of this routine is that you use in your code, without changing the Class code.
The function could of course also be done in the Class code.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Many thanks Klaus
I add the function in the standard class.
 
Upvote 0
Top