Android Question [B4X] [XUI] How to get a Canvas from a B4XCanvas?

Marcob

Member
Licensed User
In B4J I can get a Canvas object from a B4XCanvas object by using:

B4X:
Dim cvs as B4XCanvas
...
Dim cv As Canvas = cvs.TargetView.GetView(0)
Unfortunately this method seems not to work in B4A.
Is there some way to switch from B4XCanvas to Canvas in B4A?
 

Marcob

Member
Licensed User
Thank you for pointing out that.
Strangely, however, this code:

B4X:
Dim cvs As B4xCanvas
...
Dim cv As Canvas = GetNativeCanvas(cvs)

Sub GetNativeCanvas (b4x As B4XCanvas) As Canvas
    Dim jo As JavaObject = b4x
    Return jo.GetFieldJO("cvs").RunMethod("getObject", Null)
End Sub
returns the following error:

java.lang.RuntimeException: Method: getObject not found in: anywheresoftware.b4a.objects.drawable.CanvasWrapper

What am I doing wrong?
 
Top