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!
Whenever you call
invalidate()on a view, it tells the Android OS to redraw it. Then it will call theonDraw()method. Since you put theinvalidate()call inside theonDraw()method, you’re basically telling the OS to constantly redraw the view. It’s a handy way to do custom animations.