I am trying to redraw the path covered on a view when a button is clicked. For this I have maintained a linked list of all the points covered by the touch event.But unfortunately nothing is draw on canvas. I have checked all the flows of control through print statements and they seemed to work fine. Please help me figure it out
The code in touch event is: x,y are event.getx(),event.gety() respectively
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
path.moveTo(x, y);
return true;
case MotionEvent.ACTION_MOVE:
path.lineTo(x, y);
ll.add(new Point((int) x, (int) y));
break;
default:
return false;
The event handler for button is
public void onClick(View v) {
setPractise = true;
path.reset();
postInvalidate();
}
The ondraw method is
protected void onDraw(Canvas canvas) {
if(!setPractise){
canvas.drawPath(path, pencil);
}
else
{
while(( p =ll.getNext()) != null){
x = (float)p.x;
y = (float)p.y;
canvas.drawLine(px, py, x, y, pencil);
System.out.println("working"+"x is "+x+" y is "+y);
px =x;
py = y;
}
}
}