Android Question Custom View "AddToParent" method implementation

Discussion in 'Android Questions' started by Cableguy, May 29, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi guys

    I'm trying to implement an "AddToParent" method but I keep hitting walls

    I want my sub declaration as this
    Sub AddToParent( v as panel, Left as int, Top as Int, Height as int, Width as int)
    my initial approach was like this

    mBase.Initialize(""'CustomView Base Panel
        v.AddView(mBase, Left, Top, Width, Height
    This is a custom view with designer support

    but I get all sort of errors... Please help
    Last edited: May 29, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why do you need to sub? Usually you will want to add the view in the DesignerCreateView sub.
  3. Cableguy

    Cableguy Expert Licensed User

    the Idea was to be able to add the view by code, wish I have successfully implemented in my NumUpDown v1.5
  4. klaus

    klaus Expert Licensed User

    Have a look at chapter 11.6 Display a custom view in the Designer in the User's Guide.
    In he ClsLimitBar2 example code the CusromView can be added either in the Designer or in the code.

    It uses four routines:
    The standard routines.

    And two addition routines:
    AddView, adds the view to the parent
    Init, initialisation routine called either by DesignerCreateView or AddView.
    Last edited: May 31, 2015
    Cableguy and RandomCoder like this.
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Thanks @klaus I'll have to refresh myself with the user manual again as I too could do with knowing how to do add designer support to a class I'm currently working on.
  6. Cableguy

    Cableguy Expert Licensed User

    I did and that is why/how I managed to implement the "AddToParent" method to my NumUpDown.
    Many thanks to you @klaus