In most cases you should
not extend AbsObjectWrapper.
AbsObjectWrapper, which is treated specially in the IDE, was created in order to simplify the "wrapping" of the views.
By using AbsObjectWrapper you can make use of Java's polymorphism features.
Lets take for example the method Activity.AddView.
public void AddView(android.view.View View, int Left, int Top , int Width, int Height) {
The first parameter is the native view.
It is not possible to pass ButtonWrapper as the first parameter as it doesn't extends View. In Basic4ppc this issue was solved by adding a ControlRef property which exposed the internal native control. However it was a bit ugly.
Basic4android solves this issue by implementing ObjectWrapper interface (which AbsObjectWrapper implements). The IDE knows that ButtonWrapper wraps android.view.Button. Therefore when the native object is required, the IDE adds getObject code automatically.
One rule that you should remember is that a class implementing ObjectWrapper should not have any instance variables.
Take for example the following B4A code:
Dim b1, b2 As Button
b1.Initialize("")
b2 = b1
----------------
This code is translated to:
ButtonWrapper b1 = new ButtonWrapper();
ButtonWrapper b2 = new ButtonWrapper();
b1.Initialize(...) //creates the native view
b2 = b1
Now consider this code:
Dim b1, b2 as Button
Dim o As Object
b1.Initialize()
o = b1
b2 = o
------------------
Translated to:
ButtonWrapper b1 = new ButtonWrapper();
ButtonWrapper b2 = new ButtonWrapper();
Object o = new Object();
b1.Initialize(...)
o = b1.getObject(); //returns the native object
b2.setObject(o);
If b1 had any instance variables then they get lost when passed to 'o'.
To conclude this complicated topic,
in most cases you should not extend AbsObjectWrapper.