-
Book Overview & Buying
-
Table Of Contents
Android Programming for Beginners - Fourth Edition
By :
Let's look at the code and the different stages that are required to get drawing, then we can quickly move on to drawing something, for real, with the Canvas demo app.
The first step is to declare the required classes; then, we need to initialize them; finally, we will perform the step that associates our drawing setup with the UI via the Activity class and the setContentView function.
The following 3 short sections are a tutorial, then we will do it for real in the first of 2 demos in this chapter.
First, we declare all the instances that we require. We can't initialize the instances right away, but we can ensure they're initialized before they are used by using lateinit.
// Here are all the objects for basic drawing
lateinit var myImageView: ImageView
lateinit var myBlankBitmap: Bitmap
lateinit var myCanvas: Canvas
lateinit var myPaint: Paint
The previous code declares references...