Android Question Panel Custom View

Discussion in 'Android Questions' started by Kiran Raotole, Sep 1, 2018.

  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I create panel custom view, but none object added in it.
    my panel custom view code :
    Code:
    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(2As Int
            Clrs(
    0) = Colors.Magenta
            Clrs(
    1) = Colors.White
            gd.Initialize(
    "TL_BR", Clrs)
        
            mBase.Background = gd
        
    End If
        
    End Sub
     
  2. npsonic

    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.
     
    Erel likes this.
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Code:
    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.
     
  4. npsonic

    npsonic Active Member Licensed User

    You still need to add your properties.

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

    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
     
  6. npsonic

    npsonic Active Member Licensed User

    Add this to your custom view class
    Code:
    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
     
  7. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    ok by this object are added by programmatically, but in visual designer its still not possible
     
  8. npsonic

    npsonic Active Member Licensed User

    You have to add everything programmatically. It's a custom view not a layout.
     
  9. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    thanks. But I think its not perfect solution. We can create this type of panel custom view too.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice