Android Question the index of the last created panel in CustomListView

Jerryk

Member
Licensed User
Longtime User
I have a piece of program where I want to get the index of the last created panel. LastVisibleIndex works fine if the created panel is visible. But if the panel is created outside the visible part, this function will not return the index of the last panel created. How to get this index?


B4X:
            clv.Add(CreateListItemSub(sup, purs, clv.AsView.Width, 70dip), sup.ProductId)
            Dim index As Int = clv.LastVisibleIndex
            ...
            Dim pnl As B4XView = clv.GetPanel(index)
            Dim lbl As B4XView = dd.GetViewByName(pnl, "lName")
            lbl.Text = "ZZZZ" <----- when it is not visible it crashes because it is not initialized
 

DonManfred

Expert
Licensed User
Longtime User
But if the panel is created outside the visible part, this function will not return the index of the last panel created.
correct.

Check clv.Size. clv.Size-1 should be the last added one
 
Upvote 0
Top