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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:09:50+00:00 2026-05-24T11:09:50+00:00

I am doing a app on images to show them in GridView, i am

  • 0

I am doing a app on images to show them in GridView, i am fetching 20 images from server. Resolution of the each image is 720*540.I used JSON parsing to fetch url and used below code to convert into Bitmap in order to set images.

public static Bitmap loadImageFromUrl(String url) {
    InputStream inputStream;Bitmap b;
    try {
        inputStream = (InputStream) new URL(url).getContent();
        BitmapFactory.Options bpo=  new BitmapFactory.Options();
        if(bpo.outWidth>500) {
            bpo.inSampleSize=8;
            b=BitmapFactory.decodeStream(inputStream, null,bpo );
        } else {
            bpo.inSampleSize=2;
            b=BitmapFactory.decodeStream(inputStream, null,bpo );
        }
        return  b;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

my app is working fine but it is taking too much time to load the images. So that my app became slow. Should i decrease the resolution of images?

how to come out of the issue?

  • 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-05-24T11:09:50+00:00Added an answer on May 24, 2026 at 11:09 am

    If you are doing a grid view to load 20 images of such resolution, I would suggest the following:

    1. Definitely reduce the size of the images. Unless you are targeting a tablet, you will be fine as most smartphones cannot achieve that resolution with 20 images.

    2. Cache images if you can.

    3. Download the images on a different thread. Store a HashMap would make it easy for you, just put all the imageviews with the image file names or other form of IDs as keys. send message to your Handler when images are downloaded and update the view after it’s decoded. You can retrieve your views directly. Just remember to check if they are still in the window. This way the images will show up one after another quickly. I don’t think multithreading the images will help, just make sure to use another thread to “push the images” and the main UI thread updates. User experience will be greatly improved then.

    Hope this helps.

    —some implementations, I don’t have the complete code with me right now—

    Have a data structure to match the views with data that comes in. very handy here.

    private HashMap<String,ImageView> pictures;
    

    When you get the list of image urls, iterate through them:

     pictures.put(id,view);
            try{
                FileInputStream in = openFileInput(id);
                Bitmap bitmap = null;
                bitmap = BitmapFactory.decodeStream(in, null, null);
            view.setImageBitmap(bitmap);
            }catch(Exception e){
                new Thread(new PictureGetter(this,mHandler,id)).start();
            }
    

    (Here the picture getter will simply fetch the image if it is not cached already and cache it)

    Code to update the image view:

     if(id!=null){
            ImageView iv = pictures.get(id);
            if(iv!=null){
                try{
                    FileInputStream in = openFileInput(id);
                    Bitmap bitmap = null;
                    bitmap = BitmapFactory.decodeStream(in, null, null);
                    iv.setImageBitmap(bitmap);
                }catch(Exception e){
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a slide-show-like web app in which the current image is drawn
I am doing image uploads as outlined in the documentation for the App Engine
Hello Am Currently Doing An App Related To Sound Modulation I need to know
I am doing an app based on tabbarController. I have a 3 tabbar items.
We are doing an app to manage and print Word, Excel, PowerPoint, and PDF
I am doing an app that requires authentication. In the index page of the
Im currently doing a console app that has to send scheduled emails. In one
I'm doing a small app in Excel, and I have the following code when
I'm doing an iOS app that crawl my youtube subscription's videos. I have a
I am doing small Silverlight app which will allow users to Create orders. I

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.