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... calls the parent class // constructor of SurfaceView // provided by the Android API super(context); }
To import the Context
class, do the following:
Place the mouse pointer on the red colored
Context
in the new constructor...