Canvas not recognized

Priamo

Member
Licensed User
Longtime User
Hi to all,

i have this code in a sub:

B4X:
        For i = 0 To Activity.NumberOfViews -1
   Dim v As View
   v=Activity.GetView (i)
   If v Is Canvas Then
                  Activity.RemoveViewAt (i)
   End If
        Next

when run got this error:

*****
Compiling code. 0.03
Compiling layouts code. 0.00
Generating R file. 0.02
Compiling generated Java code. Error
B4A line: 255
If v Is Canvas Then
javac 1.7.0_03
src\android\xyz\main.java:1110: error: inconvertible types
if (_v.getObjectOrNull() instanceof anywheresoftware.b4a.objects.drawable.CanvasWrapper) {
^
required: CanvasWrapper
found: View
1 error
*****

if i try this code with a panel all ok, but tha panel is not good in this case for me, i need of a canvas because i must rotate the text.
I don't know the mean of the error, How can resolve it?
thanks to all.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Canvas is not a View but 'only' a drawing object related to a View.
What's the target view of the Canvas?
You should remove this view instead of the canvas.
But why do you want to remove the canvas (the target View)?

Best regards.
 
Upvote 0

Priamo

Member
Licensed User
Longtime User
Thanks for your response,

i need to rotate text, and i found some post that suggest to use the canvas for to get the rotation of the text.
I use one canvas c1 on start app for visualize the text "GO!!!", after a certain time i use another canvas C2 for visualize "STOP!!!". Now, when i visualize "GO", i must cancel C2 with c2.removeClip if on, and when visualize c2, i must cancel c1 GO with c1.removeClip, at least this is my intention, because when the c2 or c1 removeclip are executed, nothing happens, both canvas are visualized. So i decide of cancel the canvas from the activity, but i can't. This is my Story :)
Where i wrong?
Thanks a lot Klaus
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I ask once again: What is the target view of the canvas ?
Ttying to make things clear:
You have a View it can be the Activity, a Panel, an ImageView or a Bitmap etc.
Then you have a Canvas which is a drawing object (drawing tool) targeted to one of the views above.
You can draw "GO" and "STOP" with the same Canavs (same tool) on a same View.
To earase "GO" or "STOP" you can either draw "GO" or "STOP" with a Transparent color or draw a surrounding rectangle of the text with the background color of the target view.

Did you have a look at the Graphics / Drawing chapters in the Beginner's and User's Guide ?

Best regards.
 
Upvote 0

Priamo

Member
Licensed User
Longtime User
Sorry Klaus, I did not set the target that was the activity. However, rereading your previous post I did as you said, I redesigned the activity, and it works. The next Your post tells me what I did. I will look at the manual, thanks for your patience.
 
Last edited:
Upvote 0
Top