Jump to content
  • Advertisement
Sign in to follow this  

Bitmap only drawn once not drawn in updated co ordinates

This topic is 2142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all

am trying to draw bitmap and redraw it in updated coorinates.but it is only drawn once.
what to do.

Code for your reference.

import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.app.Activity;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
public class MainActivity extends Activity {
private PowerManager mPowerManager;
//private WindowManager mWindowManager;
//private Display mDisplay;
private WakeLock mWakeLock;

protected void onCreate(Bundle savedInstanceState) {
setContentView(new BitmapView(this));
// Get an instance of the PowerManager
mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
// Create a bright wake lock
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()

protected void onResume() {
* when the activity is resumed, we acquire a wake-lock so that the
* screen stays on, since the user will likely not be fiddling with the
* screen or buttons.

// Start the simulation

protected void onPause() {
* When the activity is paused, we make sure to stop the simulation,
* release our sensor resources and wake locks
// Stop the simulation
// mSimulationView.stopSimulation();
// and release our wake-lock

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.View;
class BitmapView extends View {
int posx=10;
int posy=10;
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.obstacle);

public BitmapView(Context context) {
public void update()


public void onDraw(Canvas canvas)
canvas.drawBitmap(bmp, posx, posy, null);



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!