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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:48:55+00:00 2026-06-16T19:48:55+00:00

I read the Universal Image Loader and I make application that has gridview and

  • 0

I read the Universal Image Loader and I make application that has gridview and this gridview get image from json. but my application load so slow, so I want to use Universal Image Loader but getView function in Universal Image Loader in ImageAdapeter class it use like that

imageLoader.displayImage(imageUrls[position], imageView, options); or for formula
imageLoader.displayImage(String, imageView, options);

So I don’t have a string to complete this formula. I just can create Object arr to store Arraylist.

How can I convert ArrayList<HashMap<String, Object>> to string or any ways to change my code?

Please confirm or advice or recommend me as you can. easy to read my code

Below this is my ImageAdapter. it work fine but so slow.

public class ImageAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<HashMap<String, Object>> MyArr = new ArrayList<HashMap<String, Object>>();

    public ImageAdapter(Context c, ArrayList<HashMap<String, Object>> myArrList) {
        context = c;
        MyArr = myArrList;
    }

    public int getCount() {
        return MyArr.size();
    }

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

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

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        viewHolder = new ViewHolder();

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.grid_item, null);
        }
        viewHolder.categoryCard = (ImageView) convertView.findViewById(R.id.category_card);
        //==================== change area
        Object arr = new ArrayList<HashMap<String, Object>>(); // make objec arr to store arraylist
        arr = MyArr.get(position).get("categoryid");
        if (arr.equals("1")) {
            viewHolder.categoryCard.setImageResource(R.drawable.card_eat);
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView1);
        } else {
            viewHolder.categoryCard.setImageResource(R.drawable.card_etc);
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView1);
        }
        // =============================
        try {
            viewHolder.imageView.setImageBitmap((Bitmap) MyArr.get(position).get("ImageThumBitmap"));
        } catch (Exception e) {
            viewHolder.imageView.setImageResource(android.R.drawable.ic_menu_report_image);
        }

        return convertView;

    }

}


// Download JSON in Background
public class DownloadJSONFileAsync extends AsyncTask<String, Void, Void> {
    String token = getIntent().getExtras().getString("token1");

    protected void onPreExecute() {
        super.onPreExecute();
        showDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
    }

    @Override
    protected Void doInBackground(String... params) {

        String url = "http://xxx.xxx.xxx/card/all/20/0/?token="+token;
        JSONArray data = null;
        try {

            JSONObject jsonObject = new JSONObject(getJSONUrl(url));

            MyArrList = new ArrayList<HashMap<String, Object>>();
            HashMap<String, Object> map;
            data = jsonObject.getJSONArray("data");
            for (int i = 0; i < data.length(); i++) {
                JSONObject c = data.getJSONObject(i);
                map = new HashMap<String, Object>();

                // Thumbnail Get ImageBitmap To Object
                map.put("cardimage", (String) c.getString("cardimage"));
                map.put("ImageThumBitmap",(Bitmap) loadBitmap(c.getString("cardimage")));
                map.put("categoryid", (String) c.getString("categoryid"));
                MyArrList.add(map);
            }

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return null;
    }

    protected void onPostExecute(Void unused) {
        ShowAllContent(); // When Finish Show Content
        dismissDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
        removeDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
    }

}

This is ImageAdapter that come from Universal Image Loader

public class ImageAdapter extends BaseAdapter {
    @Override
    public int getCount() {
        return imageUrls.length;
    }

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

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ImageView imageView;
        if (convertView == null) {
            imageView = (ImageView) getLayoutInflater().inflate(R.layout.item_grid_image, parent, false);
        } else {
            imageView = (ImageView) convertView;
        }
                     // I want to do like this
        imageLoader.displayImage(imageUrls[position], imageView, options);

        return imageView;
    }
}
  • 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-16T19:48:56+00:00Added an answer on June 16, 2026 at 7:48 pm

    if you want to keep the ArrayList<HashMap<String, Object>> you have to create a new String[] this way:

    String[] urls = new String[MyArrList.size()];
    for(int i=0; i<MyArrList.size(); i++){
       urls[i] = MyArrList.get(i).get("cardimage");
    }
    

    PS. I’ve used the variable name MyArrList as you declared in your code, by the way it’s not a good idea to start a variable name with a capital letter.

    PS2. I think that if you want to use the Universal Image Loader you’ll maybe no longer need to store each Bitmap in the HashMap

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

Sidebar

Related Questions

I am using the universal image loader in an app that needs to fetch
Hi I just added cellspacing to get space between the cell, but this has
I'm using Uinversal Image Loader in my application, I need to load the images
I read a text file to get some info from it and later on
I've been evaluating NOSTRA 's Universal-Image-Loader library to asynchronously download images and show them
Get all alarms saved in the alarm application here I have read there is
I'm trying to read the Application.revision property from a application.properties file into a variable
Possible Duplicate: What is the performance impact of CSS’s universal selector? Ive read that
Since there is currently no universal way to read live data from an audio
I made an application for iPhone and now I want to make it universal

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.