Coding the LiveDrawingActivity class
Let's get started with coding the Activity
-based class. We called this class LiveDrawingActivity,
and it was auto-generated for us when we created the project.
Add the first part of the code for the LiveDrawingActivity
class:
import android.app.Activity; import android.graphics.Point; import android.os.Bundle; import android.view.Display; public class LiveDrawingActivity extends Activity { private LiveDrawingView mLiveDrawingView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); mLiveDrawingView = new LiveDrawingView( this, size.x, size.y); setContentView(mLiveDrawingView); } }
The preceding code shows a number of errors, and we will talk about them shortly.
The code gets the number of pixels (wide and high) for the device...