there are some days that I'm working on a project but I have a problem:
I need to draw over a bitmap everytime that my local position has been changed, but if i call my on method draw(canvas), it doesn't work. Can someone tell me why ??
This is the code:
Using java Syntax Highlighting
- private class MyView extends View{
- public MyView(Context context) {
- super(context);
- // TODO Auto-generated constructor stub
- }
- protected void onDraw(Canvas canvas){
- super.onDraw(canvas);
- String path=getIntent().getStringExtra("path");
- Bitmap myBitmap = BitmapFactory.decodeFile(path);
- canvas.drawBitmap(myBitmap, 0, 0, null);
- Paint paint = new Paint();
- paint.setStyle(Paint.Style.FILL);
- // draw a solid blue circle
- paint.setColor(Color.BLUE);
- canvas.drawCircle(20, 20, 15, paint);
- //drawCircle(canvas);
- LocationManager lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
- lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new MyLocationListener(canvas));
- }
- private class MyLocationListener implements LocationListener{
- private Canvas canvas;
- public MyLocationListener (Canvas canvas){
- this.canvas=canvas;
- //drawCircle(canvas);
- }
- public void onLocationChanged(Location arg0) {
- // TODO Auto-generated method stub
- drawCircle(canvas);
- }
- public void onProviderDisabled(String arg0) {
- // TODO Auto-generated method stub
- }
- public void onProviderEnabled(String arg0) {
- // TODO Auto-generated method stub
- }
- public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
- // TODO Auto-generated method stub
- }
- }
- public void drawCircle(Canvas canvas){
- Paint paint = new Paint();
- paint.setStyle(Paint.Style.FILL);
- // make the entire canvas white
- //paint.setColor(Color.WHITE);
- canvas.drawCircle(40, 40, 15, paint);
- }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

