How to draw a straight line between two point on canvas with fingure in android
<p>Hi I am beginner in android development. I am developing a paint like application. I have already drawn some points on the canvas. Now I want to draw line between these points through fingure.I dont konw how i can do this. I am not using google maps. </p>

<pre><code> package com.example.point;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class DrawView extends View implements OnTouchListener {
    private static final String TAG = "DrawView";

    List&lt;Point&gt; points = new ArrayList&lt;Point&gt;();
    List&lt;Point&gt; points1 = new ArrayList&lt;Point&gt;();
    List&lt;Point&gt; points2 = new ArrayList&lt;Point&gt;();
    Paint paint = new Paint();
PointF firstpoint=new PointF(100,100);
PointF secondpoint=new PointF(200,200);
Path path=new Path();
    public DrawView(Context context) {
        super(context);
        setFocusable(true);
        setFocusableInTouchMode(true);

        this.setOnTouchListener(this);

        paint.setColor(Color.BLACK);

        paint.setAntiAlias(true);
    }

    @Override
    public void onDraw(Canvas canvas) {


        paint.setStrokeWidth(3);
        canvas.drawPoint(100, 100, paint);
        canvas.drawPoint(200, 200, paint);
        canvas.drawPoint(200, 400, paint);
        Point p=new Point();
        Point p1=new Point();
        //p1=points.get(1);
        for(int i=points.size()-2;i&lt;points.size();i++)
        {

            p=points.get(i);
            //if(p1.x==100 &amp;&amp; p1.y==100)
        //canvas.drawLine(100, 100, p.x, p.y, paint);
    //  path.moveTo(100, 100);
        //path.lineTo(200, 200);
        //canvas.drawPath(path, paint);
        }




    }

    public boolean onTouch(View view, MotionEvent event) {

        /*if(event.getAction()==MotionEvent.ACTION_MOVE)
        {
         Point point1 = new Point();          
            point1.x = event.getX();
            point1.y = event.getY();
            points.add(point1);
            invalidate();
            Log.d(TAG, "point: " + point1);


        }*/
        //if(event.getX()==100 &amp;&amp; event.getY()==100)
        //{
            if(event.getAction()==MotionEvent.ACTION_MOVE)
            {
            Point point1 = new Point();          
            point1.x = event.getX();
            point1.y = event.getY();
            points.add(point1);

            invalidate();
            Log.d(TAG, "point: " + point1);
            //}

        }
        //return false;
        return true;



        /*switch (event.getAction()) {
         case MotionEvent.ACTION_DOWN:
             Point point = new Point();          
             point.x = event.getX();
             point.y = event.getY();
             points.add(point);
             invalidate();
             Log.d(TAG, "point: " + point);

             return true;

         case MotionEvent.ACTION_MOVE:
             Point point1 = new Point();          
             point1.x = event.getX();
             point1.y = event.getY();
             points1.add(point1);
             invalidate();
             Log.d(TAG, "point: " + point1);

             return true;

         case MotionEvent.ACTION_UP:

             Point point2 = new Point();          
             point2.x = event.getX();
             point2.y = event.getY();
             points2.add(point2);
             invalidate();
             Log.d(TAG, "point: " + point2);

             return true;
         }
     return false;

        //        return true;*/
    }
}

class Point {
    float x, y;

    @Override
    public String toString() {
        return x + ", " + y;
    }
}
</code></pre>

<p>I want to just draw a straight line between these points with fingure. If my fingure move far from that particular point after that i move back my fingure than the line drawn will be erased. i.e. the line only drawn between these particular points.</p>
