RotatingNeedle Example - Help Needed

MCU01

Member
Licensed User
Longtime User
Hi all,

I'm new to Basic4Android and I have been playing with the examples in the beginner's guide. I have been modifying and playing with the RotatingNeedle example and I have a question. I want the user to be able to tap on the compass and make something happen. For example, I want this code to work

Code:
Sub imvCompass_Click

   .... do something

End If
But it just doesn't work :BangHead:. Since the ImageView is associated with a rectangle and a canvas the above code just doesn't work.

Thank you all for your help,

Robert
 
Can you upload your project (File - Export as zip) ?

It's the same project as in the guide. Just add the lines

Code:
Sub imvCompass_Click   
   btnMode.text = "texting"   'Any code to test the sub
End If

Should it work or not? Thank you.
 
Upvote 0
You should change line 24 :
Code:
imvCompass.Initialize("")
to
Code:
imvCompass.Initialize("imvCompass")
It's necessary to declare an EventName to get the event routine working.
As no event was required in the original code, so no EventName was given.

Best regards.
 
Upvote 0
You should change line 24 :
Code:
imvCompass.Initialize("")
to
Code:
imvCompass.Initialize("imvCompass")
It's necessary to declare an EventName to get the event routine working.
As no event was required in the original code, so no EventName was given.

Best regards.

Thank you Klaus. That fixed it.

Robert
 
Upvote 0
Graphics not fully displayed

I have just been playing with the rotating needle example and thought i would use different graphic file (attached). i changed to code to load the files below:

Code:
bmpCompass.Initialize(File.DirAssets,"compass1.png")
bmpNeedle.Initialize(File.DirAssets,"compassneedle.png")

The problem i am getting is that the compass1.png seems to be too big for the box and you only see the center part of the graphic, not the circle with the graticules.

the rest of the code has not changed, can anyone see why it doesn't work correctly

thanks
 

Attachments

  • compass1.png
    compass1.png
    22.1 KB · Views: 546
  • compassneedle.png
    compassneedle.png
    292 bytes · Views: 678
Upvote 0
You should move this line
Code:
imvCompass.Bitmap = bmpCompass
after this line
Code:
RectCompass.Initialize(0, 0, bmpCompass.Width, bmpCompass.Height)
imvCompass.Bitmap = bmpCompass
This happend when the densitiy is grater than 1.

Best regards.
 
Upvote 0
Thanks, that was it was :)
 
Upvote 0
Just another pair of images for the compass.

Thank you all for your help.
 

Attachments

  • Compass.png
    Compass.png
    137.9 KB · Views: 703
  • Needle.png
    Needle.png
    5.7 KB · Views: 725
Upvote 0
Back
Top