Can anyone help me to understand this ?
It's as if something clears the screen inbetween my drawing calls.

I can get similar incomplete drawings with other sequences too :-(

Is there a way to figure out which events are on the queue for the UI
thread while debugging ?

        Danny

On Sat, 2010-06-19 at 11:54 +0200, Danny Backx wrote:
> Hi,
> 
> I must be misunderstanding something. I am trying to draw some simple
> stuff, and things appear to clear (so not to display) in moments I don't
> expect it. The sample included is a simplified version of a larger
> application I'm porting to Android.
> 
> What I would expect is a circle in green, with a geometry (looking like
> a rather silly satelite) composed out of three red polygons, drawn in
> the circle.
> 
> Can anyone tell my why this is not happening ?
> 
> Thanks,
> 
>       Danny
> 
> package info.backx.testdraw1;
> 
> import android.app.Activity;
> import android.content.Context;
> import android.graphics.Canvas;
> import android.graphics.Color;
> import android.graphics.Paint;
> import android.graphics.Path;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.SurfaceHolder;
> import android.view.SurfaceView;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.Button;
> import android.widget.LinearLayout;
> 
> public class DrawActivity extends Activity {
>         public DrawActivity thiz;
>         Panel p;
>         
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>        
>         thiz = this;
>         
>         LinearLayout ll = new LinearLayout(this);
>         ll.setOrientation(LinearLayout.VERTICAL);
> 
>         Button quit = new Button(this);
>         quit.setOnClickListener(mDoitClick);
>         quit.setText("Do it");
>         ll.addView(quit);
>         
>         p = new Panel(this);
>         ll.addView(p);
>         
>         setContentView(ll);
>     }
>     
>     OnClickListener mDoitClick = new OnClickListener() {
>         public void onClick(View v) {
>                 Log.e("Test", "DoitClick");
>                 
>                 p.erase();
>                 p.DrawPolygon(1, 4, new float[] {10, 95, 17, 88, 20, 95,
> 18, 97});
>                 p.DrawPolygon(1, 4, new float[] {25, 100, 32, 103, 25,
> 110, 22, 103});
>                 p.DrawPolygon(1, 4, new float[] {25, 90, 30, 95, 20,
> 105, 15, 100});
>         }
>     };
>     
>     
>     public class Panel extends SurfaceView implements
> SurfaceHolder.Callback {
>         public Panel(Context context) {
>                 super(context);
>                 getHolder().addCallback(this);  
>         }
> 
>         @Override
>         public void surfaceChanged(SurfaceHolder arg0, int arg1, int
> arg2, int arg3) {
>         }
> 
>         @Override
>         public void surfaceCreated(SurfaceHolder arg0) {
>         }
> 
>         @Override
>         public void surfaceDestroyed(SurfaceHolder arg0) {
>         }
> 
>         public void DrawPolygon(int filled, int count, float[] points)
>         {
>                 int     i;
>                 Path path = new Path();
>                 Paint paint = new Paint();
>                 paint.setColor(Color.RED);
>                 paint.setStyle(Paint.Style.FILL_AND_STROKE);
>                         
>                 Canvas canvas = getHolder().lockCanvas();
>                 path.moveTo(points[0], points[1]);
>                 for (i=1; i<count; i++) {
>                         path.lineTo(points[i*2], points[i*2+1]);
>                 }
>                 path.close();                   
>                 canvas.drawPath(path, paint);
>                 getHolder().unlockCanvasAndPost(canvas);
>         }
>         
>         public void erase() {
>                 Canvas canvas = getHolder().lockCanvas();
>                 Paint paint = new Paint();
>                 paint.setColor(Color.GREEN);
>                 canvas.drawCircle(20, 100, 15, paint);
>                 getHolder().unlockCanvasAndPost(canvas);
>         }
>     }
> }
> 
> -- 
> Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
> 
> 
> 

-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to