Android Question Panel Custom View

Kiran Raotole

Active Member
Licensed User
I create panel custom view, but none object added in it.
my panel custom view code :
B4X:
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase.Initialize("mBase")
    mBase = Base
    Base.AddView(mBase,0,0,Base.Width,Base.Height)
    Log(Props.Get("Elevation"))
    Base.Elevation = Props.Get("Elevation")
    
    If Props.Get("NoDefaultBackground")="N" Then
        Dim gd As GradientDrawable
        Dim Clrs(2) As Int
        Clrs(0) = Colors.Magenta
        Clrs(1) = Colors.White
        gd.Initialize("TL_BR", Clrs)
    
        mBase.Background = gd
    End If
    
End Sub
 

npsonic

Active Member
Licensed User
Do not initialize mBase or add mBase as view to base view.
Just leave mBase = Base, so like the code tells you mBase is the Base after that line.
 

Kiran Raotole

Active Member
Licensed User
B4X:
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase = Base   
End Sub
I change DesignerCreateView like this still its not working.
 

npsonic

Active Member
Licensed User
You still need to add your properties.

B4X:
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase = Base
    'Your properties
    Base.Elevation = Props.Get("Elevation")
End Sub
 

Kiran Raotole

Active Member
Licensed User
ok, i will add my property. but, right now i want to use panel for add object in it.
but its not adding any object
 

npsonic

Active Member
Licensed User
ok, i will add my property. but, right now i want to use panel for add object in it.
but its not adding any object
Add this to your custom view class
B4X:
Public Sub AddView (View As View, Left As Int, Top As Int, Width As Int, Height As Int)
    mBase.AddView(View,Left,Top,Width,Height)
End Sub
 

npsonic

Active Member
Licensed User
ok by this object are added by programmatically, but in visual designer its still not possible
You have to add everything programmatically. It's a custom view not a layout.
 
Top