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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:34:00+00:00 2026-06-18T05:34:00+00:00

I have an animation with 12 images that displays as a loading image. It

  • 0

I have an animation with 12 images that displays as a loading image. It works fine on its own, but when I use my httpClient class to get content from the online db, it freezes completely and when the content is done fetching, you can see the animation stopped on a different image.

How can I make that the image load while the content is being fetched from the db ?

Here is some code:

Class members:

ImageView loading;
AnimationDrawable loadAnimation;

onCreate:

    LinearLayout main = (LinearLayout) findViewById(R.id.loading);
    loading = new ImageView(this);
    loading.setImageResource(R.drawable.loading);
    loadAnimation = (AnimationDrawable)loading.getDrawable();
    main.addView(loading);

I use this to start the animation before the content is fetched:

loadAnimation.start();

And this when it is done fetching:

loadAnimation.stop();
  • 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-18T05:34:01+00:00Added an answer on June 18, 2026 at 5:34 am

    The reason this is happening is that you are performing database operations on the main thread, which freezes the UI while your blocking code is executing. To avoid this, you need to perform those operations in a different thread. Look into using AsyncTask to see an example of how to download files asynchronously.

    In your case, start the animation in onPreExecute() and stop it in onPostExecute().

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

Sidebar

Related Questions

I have following code that displays an Image with letters, public class MainActivity extends
i have a div that it have image content .i wanna implement animation when
i want create image animation , i have 50 images with png format now
I have a list of images that I'm trying to move but it isn't
I have a web page that displays .gif images, I want to display only
I have a simple form that displays an animation when it opens and closes:
I have a program that displays an animation with a fixed frame rate (say
I have an image that I want to use as the background for every
I have a page that displays a spinner animation while dynamic content is loaded
I have a problem with switching images in android. I want to create animation

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.