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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:43:54+00:00 2026-06-08T19:43:54+00:00

I have an imageview which is loading an image from the internet. I am

  • 0

I have an imageview which is loading an image from the internet. I am loading the image from the web and converting it into a bitmap image using an async task. I’d like to display a static image in my imageview and have a progress spinner on top of the imageview while the image is loading. The problem is i have the progress spinner within my xml and I can’t use it within my async task and I do not know how to make the progress spinner visible within the imageview as well. How do I go about doing this ? Here is my async task class :

public class LoadImage extends AsyncTask<Void, Void, Bitmap>{

    Context callingContext = null;

    ImageView view;
    String b = null;
    ListView lv;
    ProgressDialog p;

    public LoadImage(Context c, ImageView view, String b){

        this.view = view;
        this.b = b;
        this.callingContext = c;
    }


    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
    //  p = (ProgressDialog) findViewById(R.id.progressBar1);
        p = ProgressDialog.show(callingContext, "Loading Events", "Retrieving data from server, please wait...", true);
    }



    public Bitmap getBit(String data){

        Bitmap bitmap;
        BitmapFactory.Options bmOptions;
        bmOptions = new BitmapFactory.Options();
        bmOptions.inJustDecodeBounds = true;
        //from web
        try {
            bitmap=null;
            InputStream is=new URL(data).openStream();
            BitmapFactory.decodeStream(is, null, bmOptions);
            is.close();
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            o2.inSampleSize = 20;
            is = new URL(data).openStream();
            bitmap = BitmapFactory.decodeStream(is, null, o2);
            is.close();
            return bitmap;
        } catch (Exception ex){
           ex.printStackTrace();
           return null;
        }

    }


    @Override
    protected Bitmap doInBackground(String... arg0) {
        // TODO Auto-generated method stub  
        Bitmap b = null;    
        URL imageUrl = null;

        b = getBit(this.b);

            return b;  
    }



    @Override
    protected void onPostExecute(Bitmap result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
        if(result == null)
            view.setImageResource(R.drawable.ic_launcher);

        p.dismiss();

    }   
} 
  • 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-08T19:43:55+00:00Added an answer on June 8, 2026 at 7:43 pm

    You can wrap an ImageView and a ProgessBar into a Relative layout. So, when the image is loading, set progressbar’s visibility to VISIBLE, and ImageView’s one to GONE. At the moment you have your Bitmap ready, invert the Visibilities.

    public class LoaderImageView extends RelativeLayout {
        private Context     context;
        private ProgressBar progressBar;
        private ImageView   imageView;
    
        public LoaderImageView(final Context context, final AttributeSet attrSet) {
        super(context, attrSet);
        instantiate(context, attrSet);
        }
    
       private void instantiate(final Context _context, AttributeSet attrSet) {
           context = _context;
           imageView = new ImageView(context, attrSet);
           progressBar = new ProgressBar(context, attrSet);
           progressBar.setIndeterminate(true);
    
           addView(progressBar);
           addView(imageView);
    
           this.setGravity(Gravity.CENTER);
       }
    
       // ...
    
       // Then, play with this method to show or hide your progressBar
       public LoaderImageView(final Context context, final AttributeSet attrSet) {
        super(context, attrSet);
        instantiate(context, attrSet);
       }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys, I have UITableView with some images, which are loading from internet. Images is
I have a class named CropImageView which is extended from ImageView . but the
I have a layout which looks like this: <LinearLayout> <ImageView> android:width=wrap_content android:height:wrap_content ... </ImageView>
I have an ImageView from which I want to copy a piece of it
I am creating an app, in which I have two small imageview (using have
I have a byte array which contains an image fetched from the net. I
I have an imageview, which uses matrix to scale/drag an image. Now I want
I have an imageview in which I want an image to be set. My
I have a UIView on which i am loading my image view as a
I have more then 100 images which I use to load in imageView using

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.