Android Question customlistview - adding panels with unkwnown height?

leitor79

Active Member
Licensed User
Longtime User
Hello,

So, we came from here; I'm building a customlistview with each item being a panel constructed with the designer and loaded with loadlayout.

The issue is that each panel has one or several autosized labels (according to font sizes, for example, among other stuff), so each panel will have different height. Not having the height is a problem when I add the item into the customlistview.

@LucaMs suggested adding an invisible panel into the activity to get (derive?) the height. But I have the same issue: activity.addview also receives the height as a parameter.

Is the solution to add a 100%y (invisible) panel, measuring each height of the items on it, and so calculate the total height of the panel?


Regards!
 

LucaMs

Expert
Licensed User
Longtime User
I don't know what is your autosized label (please post its link).

Could you do something like:
B4X:
Dim MyAutosizedLabel As AutosizedLabel
MyAutosizedLabel.Initialize("")
MyAutosizedLabel.Visible = False
Activity.AddView(MyAutosizedLabel, 0,0,0,0)
MyAutosizedLabel.TextSize = 18
MyAutosizedLabel.Text = "Ciao"

Dim ItemHeight As Int = MyAutosizedLabel.Height
MyAutosizedLabel.Remove

Dim pnlItem As Panel
pnlItem.Initialize("pnl")
' Add views to the pnlItem
'...
CustomListView1.Add(pnlItem, ItemHeight, "some value")

?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…