I saw this in Textview class of android:
@Override
protected void onDraw(Canvas canvas) {
restartMarqueeIfNeeded();
// Draw the background for this view
super.onDraw(canvas);
In View
class of android, I see that it is empty:
/**
* Implement this to do your drawing.
*
* @param canvas the canvas on which the background will be drawn
*/
protected void onDraw(Canvas canvas) {
}
Why would anybody call method of super class if it's empty?
Where is the method called with parameter canvas?
Is the parameter canvas passed automatically by the android system?
When is ondraw method called and by whom?
When it's overridden ,is the method of subclass called instead of superclass'?
This is my custom view for example:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
}
}
class MyView extends View {
public MyView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
}
Who calls MyView.OnDraw method?
There must be some one line of code that calls Myview.Ondraw method.Isnt'it?