上QQ阅读APP看书,第一时间看更新
Setting the Activity content
Finally, before we can see our drawing we tell Android to use our ImageView
called myImageView
as the content to display to the user.
// Associate the drawn upon Bitmap with the ImageView myImageView.setImageBitmap(myBlankBitmap); // Tell Android to set our drawing // as the view for this app // via the ImageView setContentView(myImageView);
The setContentView
method is part of the Activity
class and we pass in myImageView
as an argument. That's it. All we must learn now is how to actually draw on that Bitmap
.
Before we do some drawing, I thought it would be useful to start a real project, copy and paste the code we have just discussed, a step at a time, into the correct place and then actually see something drawn to the screen.
Let's do some drawing.