Coding the LiveDrawingView class
Remember that LiveDrawingView
cannot see the variables in LiveDrawingActivity
. By using the constructor, LiveDrawingActivity
is providing LiveDrawingView
with a reference to itself (this
) as well as the screen size in pixels contained in size.x
and size.y
. Add this constructor to LiveDrawingView
. The code must go within the opening and closing curly braces of the class. It is convention, but not mandatory, to place constructors above other methods but after member variable declarations:
// The LiveDrawingView constructor // Called when this line: // mLiveDrawingView = new LiveDrawingView(this, size.x, size.y); // is executed from LiveDrawingActivity public LiveDrawingView(Context context, int x, int y) { // Super... ...
Get Android Programming for Beginners - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.