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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:03:27+00:00 2026-06-17T10:03:27+00:00

I’m a beginning programmer. I’m trying use Universal image loader to display images parsed

  • 0

I’m a beginning programmer.
I’m trying use Universal image loader to display images parsed from site, but it is not work. What am I doing wrong?

Thanks.

This is a test programm.

package com.example.imageloader;

public class MainActivity extends ListActivity {

private final String URL = "Site_URL";
private ArrayList<Order> listItems = null;
private myAdapter myAdapter;
private ProgressDialog pd;  
ImageLoader imageLoader;    
DisplayImageOptions options;    
String imgSrc;
ListView lv;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listItems = new ArrayList<Order>(); 
    this.myAdapter = new myAdapter(this, R.layout.list_item, listItems);
    setListAdapter(this.myAdapter);

    new Parse().execute(URL);

    lv = getListView();

    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(MainActivity.this));

    options = new DisplayImageOptions.Builder()
    .showStubImage(R.drawable.ic_launcher)
    .showImageForEmptyUri(R.drawable.ic_launcher)
    .cacheOnDisc()
    .cacheInMemory()
    .build();
}


private class Parse extends AsyncTask<String, Integer, ArrayList<Order>> {
    @Override
    protected void onPreExecute() {
        pd = new ProgressDialog(MainActivity.this);
        pd.setMessage("Loading");
        pd.show();
    }

    @Override
    protected ArrayList<Order> doInBackground(String... urls) {
        listItems.clear();              
        try {
            Document doc = Jsoup.connect(URL).get();
            Elements img = doc.select("img");
            for (Element src : img) {
                String imgSrc = src.attr("src");

                System.out.println(imgSrc);                         

                Order o = new Order();
                o.setLink(imgSrc);
                o.setTextName(imgSrc);
                listItems.add(o);                   
            }               

        } catch (IOException e) {
            e.printStackTrace();
        }
        return listItems;
    }

    @Override
    protected void onPostExecute(ArrayList<Order> listItems) {  
        myAdapter = new myAdapter(MainActivity.this, R.layout.list_item, listItems);
        setListAdapter(myAdapter);
        myAdapter.notifyDataSetChanged();
        pd.dismiss();
    }
}
}

Custom adater
I get an error here

package com.example.imageloader;

public class myAdapter extends ArrayAdapter<Order> {

private LayoutInflater lInflater;
private ArrayList<Order> data;
DisplayImageOptions options;
ImageLoader imageLoader;
private Order o;
String imgSrc;  

public myAdapter(Context c, int listItem, ArrayList<Order> data) {
    super(c, listItem, data);
    this.data = data;
    lInflater = LayoutInflater.from(c);
}

public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;

    if (convertView == null) {
        convertView = lInflater.inflate(R.layout.list_item, null);
        holder = new ViewHolder();
        holder.img = (ImageView) convertView.findViewById(R.id.image);
        holder.textName = (TextView) convertView.findViewById(R.id.text);
        convertView.setTag(holder);

        holder.textName.setOnClickListener(new OnItemClickListener(position));

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    o = data.get(position);
    holder.textName.setText(o.getTextName());
    holder.img.setTag(o);

        try {
            imageLoader.displayImage(o.getLink(), holder.img, options); // NullPointerException here!
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    } else {            
        return null;            
    }
    return convertView;


static class ViewHolder {
    ImageView img;
    TextView textName;
}
}

Log

01-16 11:55:04.480: W/System.err(19105): java.lang.NullPointerException
01-16 11:55:04.496: W/System.err(19105):    at          com.example.imageloader.myAdapter.getView(myAdapter.java:62)
  • 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-17T10:03:28+00:00Added an answer on June 17, 2026 at 10:03 am

    you should add this code

    imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(c));
    

    in your constructor of myAdapter.
    and also checks the id of imageview, is it correct or at right place where you are referencing it to

    holder.img = (ImageView) convertView.findViewById(R.id.image);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place

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.