B4J Question How to get the native view instance of a wrapped view ?

TelKel81

Active Member
Licensed User
For example, I have an object of the comboboxwrapper class. How do I get the native combobox instance ?

I get the wrapper class as a result of running this code :
B4X:
Dim obj As Object = Control.As(JavaObject).RunMethod("_getview", Array(Null))
GetView returns the mView field (a ComboBox, big surprise) declared in the Control class.

If I define the return type of the GetView method to Combobox, "obj" is a comboboxwrapper.
If I define the return type of the GetView method to Object, "obj" is a combobox. But I wish to have ComboBox as return type.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Defining the type of 'obj' s Object unwraps the ComboxWrapper and gives you the unwrapped ComboBox object as you have found. That is all you can do within B4X code as you can't use Java native types. You can use JavaObject to manipulate the ComboBox as you want. Despite it being declared as Object, it is still a ComboBox instance.
 
Upvote 0
Top