Android Question Help on canvas in a widget....

riccardomarchetto

Member
Licensed User
Longtime User
Hi to everyone,
I have some problem with this widget code. There's no error compiling it but I don't see any image.

Thank you in advance who help me.

B4X:
sub Process_Globals
    dim freccia as bitmap
end sub

Sub DisegnaFreccia()
Dim canvas1 As Canvas
Dim path1 As Path
Dim DstRect As Rect

freccia.InitializeMutable(100dip,100dip)
canvas1.Initialize2(freccia)

DstRect.Initialize(0dip,0dip,100dip,100dip)

'dummy draw
path1.Initialize(50dip, 50dip)
path1.LineTo(100dip, 50dip)
path1.LineTo(50dip, 0dip)
path1.LineTo(0dip, 50dip)
path1.LineTo(50dip, 100dip)

canvas1.ClipPath(path1) 'clip the drawing area to the path
canvas1.DrawPath(path1,Colors.Magenta,True,10dip)
canvas1.DrawBitmap(freccia,Null,DstRect)

rv.SetImage("ImageView1",freccia)
rv_RequestUpdate

End Sub

obviously ImageView1 is a view in the Widget Layout.

bye
 
Last edited:

riccardomarchetto

Member
Licensed User
Longtime User
Thank Erel for answer.

I've followed your indication in this way:

1) freccia is initialized during service start up
2) I've remove the canvas1.drawbitmap line


the compiler now give me this error:
java.lang.NoSuchFieldException: widget_imageview1

at this line

B4X:
rv.SetImage("ImageView1",freccia)
 
Last edited:
Upvote 0
Top