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 9024793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:06:48+00:00 2026-06-16T06:06:48+00:00

why my imageview is not updating in the for loop,only the image from last

  • 0

why my imageview is not updating in the for loop,only the image from last url is showing in the imageview not all the images,what i am doing wrong?

public class LoadImageActivity extends Activity {
    ImageView image_view;
    Bitmap bitmap;

    String[] imageLocation={
            "http://wallbase1.org/thumbs/rozne/thumb-499842.jpg",
            "http://ns3002439.ovh.net/thumbs/rozne/thumb-2493796.jpg",
            "http://ns3002439.ovh.net/thumbs/rozne/thumb-2486664.jpg" };  

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        image_view = (ImageView)findViewById(R.id.imageview);

        for (int i = 0; i < 2; i++) {
            bitmap = loadImage(imageLocation[i]);
            image_view.setImageBitmap(bitmap);

            Animation rotate = AnimationUtils.loadAnimation(LoadImageActivity.this, R.anim.rotate);
            findViewById(R.id.imageview).startAnimation(rotate);
        }
    }

    public  Bitmap loadImage(String image_location){
        URL imageURL = null;
        try {
            imageURL = new URL(image_location);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        try {
            HttpURLConnection connection = HttpURLConnection)imageURL.openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream inputStream = connection.getInputStream();

            bitmap = BitmapFactory.decodeStream(inputStream);//Convert to bitmap
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bitmap;
    }
}
  • 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-16T06:06:49+00:00Added an answer on June 16, 2026 at 6:06 am

    Well, at first, how slow is you device that you would switch between images in two successing lines of code (effectively)?

    Secondly, the system has to be layouted first which happens after onCreate() returns. What you did is:

    -set reference to bitmap that will be shown when layouted
    -changed that reference
    -let the system do the layout (Question: Which reference will be read?)
    

    It looks like you want to set the first bitmap, rotate it and then set the other bitmap.
    What you need to do is:

    -set bitmap
    -start animation with an Animation.AnimationListener, which sets the second bitmap in onAnimationEnd().
    

    @Thanks to Adam!

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

Sidebar

Related Questions

I have a pr0blem with the ImageView, I can not view my image and
java.lang.OutOfMemoryError: bitmap size exceeds VM budget. i am updating images to a gridview from
I am trying to load bitmap image to listview from sdcard but imageview is
I have problems updating the image of an UIImageView from within a method that
i did an application which has imageview to capture image from camera and a
I'm not sure what I'm doing wrong, but Xcode keeps saying Expected expression. What
I want to do something like this: For some reason the ImageView is not
I am not able to align a text below imageview in a listview. below
Method1 (Not working) I declared an Imageview in XML <ImageView android:id=@+id/imageView1 android:layout_height=wrap_content android:layout_weight=0.21 android:layout_width=100dp
Table view cell imageView is working on the simulator but not on the device..

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.