Android development: Loading bitmaps

If you want to add graphics to your application you can use the following information

Create a custom Activity like this

Create your own View ( in this example StrategoGameView)

I personally find it a good practice to call an initialize method in your constructor. This way you can decide if you want to make it public so when needed you can reinitialize easily.

Now if you want to add a Bitmap to your application you need to do the following things

Add a res/drawable directory to your project

create some fancy images and save them in this directory.

After a rebuild you can get a pointer to the using the R.drawable object like this

to draw the bitmap to the screen you need to add a onDraw method to your View like this:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.