I saw this in the Textview class for android:
@Override protected void onDraw(Canvas canvas) { restartMarqueeIfNeeded();
In the View android class, I see that it is empty:
protected void onDraw(Canvas canvas) { }
Why would anyone call a superclass method if it is empty?
Where is the method called using the parameter canvas?
Is the parameter canvas transferred automatically by the android system?
When is the ondraw method called and by whom?
When it is redefined, is the subclass method used instead of the 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 is calling the MyView.OnDraw method?
Should there be any one line of code that calls the Myview.Ondraw.Isnt'it method?
source share