Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:18:39+00:00 2026-06-14T23:18:39+00:00

I have the following code: public void loop1(int times, SpriteObject[] obj){ for(int i =

  • 0

I have the following code:

    public void loop1(int times, SpriteObject[] obj){
        for(int i = 0; i < times; i++){
            obj[i] = new SpriteObject(BitmapFactory.decodeResource(gv.getResources(),  R.drawable.bar1), 500,720);
        }
     }

However, when I draw this on the view it does not stay as i expected.
If I use obj[i].setX(10) and obj[5].setX(20). Only the second one appears as it is refreshing and only taking the last object. is it possible to reuse the drawables like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:18:40+00:00Added an answer on June 14, 2026 at 11:18 pm

    I don’t completely understand what you’re trying to accomplish here and to me it seems like your resource load method is completely set up wrong. From what I can tell, you’re trying to make two similar bitmaps move around.

    First, for simple drawing applications or games you would use view or surfaceview so you must implement that. Secondly, the way I create moving bitmaps is to first create Bitmap variables to hold the respective bitmaps and then I create a separate classes for each respective Bitmap. In the classes I have the following.

    public float x = 0;
    public float y = 0;

    So with this in mind all you have to do to draw the bitmaps is in the onDraw method of View you use this method.
    canvas.drawBitmap(bitmapVariable, bitmap.x, bitmap.y, null);

    If you wanted to move the bitmaps you would just have to change the X and Y of the respective bitmap. Either in a separate method or in your update loop.

    Ultimately, I think you’re understanding bitmaps wrong. Once created you don’t need to recreate it to redraw it at a different location unless the bitmap was garbage collected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SO I have the following code public void rand(int N){ double[]x=new double[N]; double[]y=new double[N];
i have the following code public static void main(String[] args) { int x=0; int
I have following code: public static void ProcessStep(Action action) { //do something here if
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: public void disconnect() { running = false; if(thread !=
I have the following code: public void Dispose() { bool append = true; using(var
I have the following code: public void BeginConvert(object data) { ConverterData cObject = (ConverterData)data;
I have the following code: public void post(String message) { final String mess =
If I have the following code: public class Foo { public void Bar() {
i have the following code: public static void Serialize() { List<string> dirs = FileHelper.GetFilesRecursive(fileDirectoryPath);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.