Reputation: 105
I need to draw something on the same canvas that onDraw() get access to.
This works fine as long as I am inside OnDraw(), but I don't know how to get that canvas when I'm outside.
Thanks for any suggestions.
@Override
protected void onDraw(Canvas canvas) {
canvas.doSomething // works fine
}
//new method to draw omething on the same canvas
mydraw(how to get canvas in here?){}
Upvotes: 2
Views: 1709
Reputation: 3854
You can try to send canvas to your own method:
@Override
protected void onDraw(Canvas canvas) {
yourMethod(canvas);
}
void yourMethod(Canvas canvas){
//TODO
//your code goes here
}
Upvotes: 2
Reputation: 1200
onDraw is called by the system, you should call do your drawing in there you could always pass he Canvas as a parameter to your myDraw method
Upvotes: 2