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, w开发者_C百科hich 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 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.
精彩评论