Reputation: 123
I subclassed View
to get an View on which the user can "draw" with his fingers. I implemented the Interface View.OnTouchListener
.
How can I trigger within the onTouch
method the redraw of the View? Do I need to implement a Thread / Runnable? I thought that invalidate()
triggers the redraw, but this doesn't work.
Upvotes: 0
Views: 1813
Reputation: 6892
Just call this.invalidate in the onTouchEvent method of your view, it really should work unless you're not doing the proper thing in your onDraw method. Make sure you're referencing to the right canvas an draw the thing in your overridden onDraw method instead of for example the constructor.
@Override
public boolean onTouchEvent(MotionEvent event) {
this.invalidate();
return true;
}
Upvotes: 1