How to draw new circle on touch and remove previous circle
<p>I can create circle on touch but can not remove the previous one. I have manage to remove the very first circle but the code is poor and it does not really work as I want. I like to draw circle every time I touch the screen and remove the previous circle . So the screen starts with a circle and as I will touch a new position the previous should be removed and there will be a new one.So how to do that part?
Here is my work:</p>

<pre><code>public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    Display display = new Display(this);
    display.init();
    display.backPaint.setColor(Color.WHITE);
    setContentView(display);
}

static class Display extends View {
    ArrayList&lt;Point&gt; points = new ArrayList();
    int touch1_x=700;
    int touch1_y=700;
    Paint backPaint;
    Paint circlePaint;
    Paint circlePaint2;

    Display(Context context) {
        super(context);
    }

    void init() {
        backPaint = new Paint();
        backPaint.setColor(Color.WHITE);
        backPaint.setStyle(Paint.Style.FILL);
        circlePaint = new Paint();
        circlePaint.setColor(Color.YELLOW);
        circlePaint2 = new Paint();
        circlePaint2.setColor(Color.WHITE);
        setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (MotionEvent.ACTION_DOWN == event.getActionMasked()) {
                   // if (event.getX(event.getActionIndex()) &gt; 100 &amp;&amp; event.getX(event.getActionIndex()) &lt; 200) {
                        touch1_x = (int) event.getX(event.getActionIndex());
                        touch1_y = (int) event.getY(event.getActionIndex());
                   // }
                    System.out.println("touch1_x ===" + touch1_x);
                    points.add(new Point(touch1_x, touch1_y));
                    points.add(new Point(touch1_x, touch1_y));
                    return true;
                }
                return false;
            }
        });
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawRect(0, 0, getWidth(), getHeight(), backPaint);
        canvas.drawCircle(touch1_x, touch1_y, 50, circlePaint);

        for(Point p: points){
            canvas.drawCircle(p.x, p.y, 50, circlePaint);

        }
        for(Point p: points){
            canvas.drawCircle(p.x, p.y, 50,circlePaint2 );
        }
    invalidate();
    }

}

}
</code></pre>