B4J Code Snippet CustomControls Base

When you create a custom control with the new version of B4J, you may need to resize it from the application eg, you remove a component from it.

The variable 'Base' is only available in the sub DesignerCreateView.

In that routine, if you take a copy of it, you can resize the control whenever you want.
B4X:
'class globals
....
Private savedBase as Pane
....

Sub DesignerCreateView( ....
...
savedBase = Base
.....
End Sub

...
savedBase.PrefHeight = ... 'etc
...
 

Cableguy

Expert
Licensed User
Longtime User
In All my custom views (B4A) I create a Panel called mBase, and in the createView I do mBase = Base, this ensures that I will always have full control over the physical appearance of my view.

It is also good practice to allow other developers to add your customview by code, by creating an AddToParent(Parent as Panel, Left as int....etc)
This way it can be created just like any other view.
 

Daestrum

Expert
Licensed User
Longtime User
@Cableguy Thank you for the hint, I managed to add the my simple Autocomplete textbox control programmatically to the scene.

It seems a bit convoluted to add to an existing scene, I am probably doing things that I don't need to.
 
Top