skypower
skypower

Reputation: 159

Basic rendering - onDraw() method question

I am declaring a class that extends activity and an inner class that extends view and contains the onDraw() method, which also contains the invalidate() method. In my overriden onCreate() method I instantiate the outer class. My question is how the onDraw() method is called, since I never call it manually.

PS: I understand this might be a simple java language trick - I admit I am not the best here!

Upvotes: 0

Views: 1557

Answers (1)

DeeV
DeeV

Reputation: 36035

Whenever you call invalidate() on a view, it tells the Android OS to redraw it. Then it will call the onDraw() method. Since you put the invalidate() call inside the onDraw() method, you're basically telling the OS to constantly redraw the view. It's a handy way to do custom animations.

Upvotes: 3

Related Questions