While developing games or applications that need to perform custom drawing on Android, you will need to write your own class, derived from SurfaceView.

While doing so, one of the problems you will face, is with regards to screen refresh. By default, the refresh facility if turned off.

To refresh the screen, you will need to either ‘invalidate’ the View object at regular intervals (possibly using a thread or a Handler or an AsyncTask) or use the setWillNotDraw(false) method call while initializing the View object.

Please note that you will need to call this method in the ‘surfaceCreated’ method of the View object.

Advertisements