Android Question Panel size is unknown. Layout may not be loaded correctly.

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
I have a class:

B4X:
Sub Class_Globals
   
    Private mBase As Panel
    Private EventName As String
    Private CallBack As Object
   
End Sub

Public Sub Initialize (vcallback As Object, vEventName As String)
   
    CallBack=vcallback : EventName=vEventName
    mBase.Initialize("mBase")
   
End Sub

Public Sub GetBase As Panel
   
    mBase.LoadLayout("mylayout")
    Return mBase
   
End Sub

In the activity I add the class:
B4X:
Dim item As myclass
item.Initialize(Me,"item")
Activity.AddView(item.GetBase,0,100dip,100%x,100dip)

And I get this log:

'Panel size is unknown. Layout may not be loaded correctly.

How to solve this?
 

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
I think it's solved


B4X:
'Class:
Public Sub GetBase As Panel
   
    Return mBase
   
End Sub

Public Sub LoadLayout

    mBase.LoadLayout("mylayout")

End Sub

'Activity:

Dim item As myclass
item.Initialize(Me,"item")
Activity.AddView(item.GetBase,0,100dip,100%x,100dip)
item.LoadLayout
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I wouldn't do it that way.
I suggest you to add an AddToParent routine in the class.

Have a look at chapter 12.3 CustomViews in the B4A User's Guide.
There you find an example that you can add either in the Designer or in the code.
 
Upvote 0
Top