hi i am trying to add undo feature to finger paint example given in API demo. but i am not able to achieve it. So far i have added all the path that are drawn in a list and redrawing it to the canvas except the last path. But it is not working. Any clue where i am going wrong.
Edit #1: My Undo Method is this
private void undo(){
if (MyPathList.size()>0) {
mCanvas.drawColor(0xFFFFFFFF);
for (int i = 0; i < MyPathList.size()-1; i++) {
Path p=(Path)MyPathList.get(i);
mCanvas.drawLine(0, 0, 20, 20, mPaint);
mCanvas.drawLine(0, 0, 80, 20, mPaint);
mCanvas.drawPath(p, mPaint);
p.reset();
}
invalidate();
}
}
Thanks in Advance.
When you drawing line for the current process like at now use drawing the like using it finger now store this points into temp_array list. now add this temp_array list into the main array list which will draw all sub array list point like wise here.
like onTouch()
always re-initialize into onTouch() method in down event and get all the point at move time get the point and store into this list now at up event time store this array list into main list.
now if you want to undo last or more you can just remove last add temp_point list from the mainPoint array List