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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:26:37+00:00 2026-06-09T12:26:37+00:00

I am having a problem when I load images from my SD card and

  • 0

I am having a problem when I load images from my SD card and display them in my listview. They initially load fine but when I start scrolling up and down the images get all mized up and are not the images that go with the corresponding list item

here is my adapter where I do everything

@Override
    public void bindView(final View view,final Context context,final Cursor cursor){
        final int id = cursor.getInt(0);;
        final QuickContactBadge image = (QuickContactBadge)view.findViewById(R.id.quickContactBadge1);
        image.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                if(!fromGame){
                    bowlerID = id;
                    Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(i,1);
                }
            }

        });
        String uri = cursor.getString(3);
        if(uri != null){
            image.setImageResource(R.drawable.ic_contact_picture);
            new LoadImage().execute(new Object[]{uri,image});
        }else{

        }

        TextView first = (TextView)view.findViewById(R.id.bListTextView);
        TextView last = (TextView)view.findViewById(R.id.bListTextView2);
        first.setText(cursor.getString(1));
        last.setText(cursor.getString(2));
    }

and my AsyncTask that I give the view that the image will show in and the uri of the image

public class LoadImage extends AsyncTask<Object,Void,Object[]>{

    @Override
    protected Object[] doInBackground(Object... params) {
        String u = (String) params[0];

        InputStream input=null;
        try {
            input = getActivity().getContentResolver().openInputStream(Uri.parse(u));
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = false;
            Bitmap og = BitmapFactory.decodeStream(input,null,options);
            int height = options.outHeight;
            int width = options.outWidth;
            BitmapFactory.decodeResource(getResources(), R.drawable.ic_contact_picture, options);

            int imageHeight = options.outHeight;
            int imageWidth = options.outWidth;
            try {
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

            float scaledHeight = ((float)imageHeight)/height;
            float scaledWidth = ((float)imageWidth)/width;

            Matrix matrix = new Matrix();
            matrix.postScale(scaledWidth, scaledHeight);

            Bitmap resize = Bitmap.createBitmap(og, 0, 0, width, height, matrix, true);
            try {
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return new Object[] {resize,params[1]};    
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public void onPostExecute(Object[] params){ 
        Bitmap resizedImage = (Bitmap)params[0];
        QuickContactBadge image = (QuickContactBadge) params[1];
        image.setImageBitmap(resizedImage);
    }

}

I am guessing it has something to do with handeling the image in the AsyncTask but how do I fix it?

  • 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-09T12:26:38+00:00Added an answer on June 9, 2026 at 12:26 pm

    I forgot to set the default image back

    image.setImageResource(R.drawable.ic_contact_picture);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load profile images (friend images) from Facebook with AS3 but I
Problem: I am having trouble implementing a recursive image lazy load in all relevant
I am having problem getting my tooltip to work when using the jQuery load()
I'm having a problem whereby I am trying to load some html onto a
I'm having a problem with LD_PRELOAD on Linux. I'm trying to load a library
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
So I have an interesting problem I am having issues with the jquery .load()
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I've been having trouble getting my images to show on the page after they

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.