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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:38:38+00:00 2026-05-22T01:38:38+00:00

Can anyone see what Im doing wrong here? I know it is a lot

  • 0

Can anyone see what Im doing wrong here? I know it is a lot of code but I do not get any errors other then that the images do not turn up inside the imageviews. The imageviews turns up but empty.

I guess Im running the asynctask in the wrong place or something?

Here’s the code:

MainActivity.java:

package se.bjornange.android.grid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;

public class mainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    GridView gridview = (GridView) findViewById(R.id.gridview);    
    gridview.setAdapter(new ImageAdapter(this));
}

}

ImageAdapter.java

package se.bjornange.android.grid;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter implements NetworkCallListener {
private Context mContext;
Bitmap thebmp;
ImageView imageView;

public ImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return aThumbUrls.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

public void onNetworkCallComplete(Bitmap bmp) {

    thebmp = bmp;

}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {


    new NetworkCallTask(this).execute(aThumbUrls[position]);

    if (convertView == null) {
        // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);

    } else {

        imageView = (ImageView) convertView;
    }

    imageView.setImageBitmap(thebmp);

    return imageView;
}

private String[] aThumbUrls = { "http://www.google.se/images/logo_sm.gif",
        "http://www.google.se/images/logo_sm.gif", "http://www.google.se/images/logo_sm.gif"
            };

@Override
public void onNetworkCallCancel() {
    // TODO Auto-generated method stub

}

}

NetworkCallListener.java

package se.bjornange.android.grid;

import android.graphics.Bitmap;

public interface NetworkCallListener {
    public void onNetworkCallComplete(Bitmap bmp); 

  public void onNetworkCallCancel();

}

NetworkCallTask.java

package se.bjornange.android.grid;


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;

public class NetworkCallTask extends AsyncTask<String, Void, Bitmap> {
NetworkCallListener listener = null;
String url;
  public NetworkCallTask(NetworkCallListener listener) {
    this.listener = listener;
  }


protected void onPreExecute() {

}

protected Bitmap doInBackground(String... params) {

    Bitmap bmImg = null;
    url = params[0];
    URL myFileUrl = null;


    try {
        myFileUrl = new URL(url);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        HttpURLConnection conn = (HttpURLConnection) myFileUrl
                .openConnection();
        conn.setDoInput(true);
        conn.connect();
        InputStream is = conn.getInputStream();

        bmImg =  BitmapFactory.decodeStream(is);

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return bmImg;
}

protected void onPostExecute(final Bitmap bmImg) {
     //imageView.setImageBitmap(bmImg);

    listener.onNetworkCallComplete(bmImg);
}

}
  • 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-22T01:38:39+00:00Added an answer on May 22, 2026 at 1:38 am

    reefer below link

    Lazy load of images in ListView

    Source is available here http://open-pim.com/tmp/LazyList.zip

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

Sidebar

Related Questions

My Get confirm isn't triggering the query? Can anyone see what I'm doing wrong?
Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)
Trying to convert the following but am having difficulty. Can anyone see where I'm
I'm at my wit's end with this. Can anyone see anything wrong with this
Does anyone know why I can't see an HTTP request that results in a
Does anyone know if this is possible? I can't see to find much info
Rails noob here so I'm not sure what I'm doing wrong. We're replacing a
Can anyone see where I could be making a mistake? The form text-box background
Can anyone let me know how can we change the value of kendo combobox
I know this is something I'm probably doing wrong, so please don't incinerate me

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.