title: Android-Draw on SurfaceView
body: <p>I am creating an app to draw free shapes on the surface screen but i could only draw separated points my problem is . i want the points to be connected to each other when i draw them not lifting my finger from the screen . i mean as long as i am touching the screen draw.here's my code so far.</p>
  
  <pre><code>   public class SurfaceViewActivity extends Activity  {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(new DrawingView(this));
  }
  
  class DrawingView extends SurfaceView {
  
      private final SurfaceHolder surfaceHolder;
      private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  
      private List&lt;Point&gt; pointsList = new ArrayList&lt;Point&gt;();
  
      public DrawingView(Context context) {
          super(context);
          surfaceHolder = getHolder();
          paint.setColor(Color.WHITE);
          paint.setStyle(Paint.Style.STROKE);
          paint.setStrokeWidth(3);
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
              if (surfaceHolder.getSurface().isValid()) {
  
                  // Add current touch position to the list of points
                  pointsList.add(new Point((int)event.getX(), (int)event.getY()));
  
                  // Get canvas from surface
                  Canvas canvas = surfaceHolder.lockCanvas();
  
                  // Clear screen
                  canvas.drawColor(Color.BLACK);
  
                  // Iterate on the list
                  for(int i=0; i&lt;pointsList.size(); i++) {
                      Point current = pointsList.get(i);
  
                      // Draw points
                     canvas.drawPoint(current.x, current.y, paint);
  
                  }
  
                  // Release canvas
                  surfaceHolder.unlockCanvasAndPost(canvas);
              }
          }
          return false;
      }
  }
  </code></pre>
  
  <p>}</p>