Android Question Problem: LoadLayout should be called only after added to parent

zombee81

Member
Licensed User
Longtime User
I've adapted the CreateListItem from the CustomListView demo, to add items to a custom list view using a loadlayout to add a predefined layout for each entry.

B4X:
Sub CreateReadingItem(dtDateTime As String, Reading As String) As Panel
    Dim p As Panel
    p.Initialize("")
   
    p.LoadLayout("ReadingItemLayout")
   
    Dim chkDateTime As CheckBox
    Dim lblReading As Label
   
    chkDateTime.Text = dtDateTime
    lblReading.Text = Reading

    Return p
End Sub

Then I'm temporarily adding data in the Activity_Create function, by using:

B4X:
ElectricityReadingsList.Add(CreateReadingItem("17/02/2014 - 10:15 PM", "005573.0"), 80dip, "")

But I get Panel.LoadLayout should only be called after the panel was added to its parent. (warning #1001), can anyone suggest a way around this?

Thanks in advance.
 
Top