On Nov 2, 9:06 am, joshbeck <[EMAIL PROTECTED]> wrote:
> On Nov 2, 9:04 am, joshbeck <[EMAIL PROTECTED]> wrote:
>
> > Thanks a million. I'll try this today and report back.
>
> > I appreciate it.
>
> > When you say 'set a flag.' Do you mean like an int? 0 or 1 kind of
> > thing?
>
> > Thanks again,
> > Pros
>
> One more thing:
> If I set a flag in OnTouchEvent that is something like this
> int myflag = 1;
>
> What is the best way to make it global so that onDraw will recognize
> it?

Ok, this keeps the background and draws a circle on top of it when I
touch the screen.
Question: How do you think I might get it to keep the old circles when
I draw new ones.
Right now when I click the canvas is completely redrawn and the first
circle I created is lost.

Thanks, that helped a lot.




import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;

public class BitmapMesh extends Activity {
        SampleView mView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mView = new SampleView(this);
        setContentView(mView);

    }

        private static class SampleView extends View {
        private  Canvas mCanvas;
        private final Paint mPaint;
        private Bitmap mBitmap;
        public float XX;
        public float YY;
        public float ZZ;

        public SampleView(Context context) {

                super(context);
                 ZZ = 0;

                 mPaint = new Paint();
                 mPaint.setAntiAlias(true);
             mPaint.setARGB(255, 255, 255, 255);
             mBitmap = BitmapFactory.decodeResource(getResources(),
 
R.drawable.darkcleanlinux);


                }

        @Override protected void onDraw(Canvas canvas) {
            mCanvas = canvas;
            if(ZZ != 0){
                canvas.drawBitmap(mBitmap, 0, 0, null);
                canvas.drawCircle(XX, YY, 20, mPaint);
            }
            else
            canvas.drawBitmap(mBitmap, 0, 0, null);

        }

       @Override public boolean onTouchEvent(MotionEvent event) {
            invalidate();

            XX= event.getX();
            YY= event.getY();
            ZZ = 1;
            return true;
        }

       private void draw2(float X, float Y) {


            mCanvas.drawCircle(X, Y, 200, mPaint);

        }

    }

}
--~--~---------~--~----~------------~-------~--~----~
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