Goodmorning everyone I have a button that when i click at it , a line is drawing between two points with this code :
private class DrawView extends View {
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
paint.setColor(colorr[thecolore[0]]);
paint.setStrokeWidth(5);
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawLine(the coordinate);
}
}
the problem is when i click for exemple two times the two lines i need are drawing, but when i loop two times and i use
button.PerformClick();
only the last line's drawing ! what's the problem here and how can i solve this . thanks
The onDraw routine needs to draw both lines. You draw it every time the view is invalidated so the onDraw routines needs both lines if you want to draw both lines. It has to draw everything in the view all over again.