I have an android application that draws a path of points in an arraylist (named 'test'). An algorithm updates the arraylist to make the path shorter each time (it uses the Travelling Salesman Problem algorithm). The problem I am facing at the moment is that the previous path does not clear, instead the new path draws over the previous one.
//this class draws a line
public void CompDrawLine(List test) {
// int d = 0;
int i=0;
test.add(test.get(0));
Point c = test.get(i);
for (i=0;i<(test.size()-1);i++) {
cPath.moveTo(c.x,c.y);
c = test.get(i+1);
cPath.lineTo(c.x,c.y);
mCanvas.drawPath(cPath,cPaint);
//cPath.reset();
}
// cPath.reset();
invalidate();
}