Android Question Custom View "AddToParent" method implementation

Cableguy

Expert
Licensed User
Longtime User
Hi guys

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

I want my sub declaration as this
B4X:
Sub AddToParent( v as panel, Left as int, Top as Int, Height as int, Width as int)

my initial approach was like this

B4X:
    mBase.Initialize("") 'CustomView Base Panel
    mBase.RemoveView
    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:

Cableguy

Expert
Licensed User
Longtime User
Why do you need to sub? Usually you will want to add the view in the DesignerCreateView sub.

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

klaus

Expert
Licensed User
Longtime 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.
Initialize
DesignerCreateView

And two addition routines:
AddView, adds the view to the parent
Init, initialisation routine called either by DesignerCreateView or AddView.
 
Last edited:
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Take 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.
Initialize
DesignerCreateView

And two addition routines:
AddView, adds the view to the parent
Init, initialisation routine called either by DesignerCreateView or AddView.

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