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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:58:41+00:00 2026-06-06T02:58:41+00:00

In my project I have a grid view which contains images. Based on my

  • 0

In my project I have a grid view which contains images. Based on my research, Universal Image Loader project is designed to download images in background. Then based of sample I set my adapter. This is the code that I have written:

package cam.astro.mania.adapters;

import java.io.File;
import java.util.ArrayList;

import com.astro.mania.activities.Contestants_Photo;
import com.astro.mania.activities.R;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DecodingType;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.ImageLoadingListener;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class ContestantsPhotoAdapter extends BaseAdapter {

    private Context context;
    private LayoutInflater myInflater;
    private Bitmap[] bitmapList;
    private Bitmap bitmap;

    private ArrayList<String> ListOfURLs;
    private ImageLoader imageLoader;
    private ProgressDialog progressBar;
    private File cacheDir;
    private ImageLoaderConfiguration config;
    private DisplayImageOptions options;


    public ContestantsPhotoAdapter(Context c) {
        context = c;
        myInflater = LayoutInflater.from(c);

        // Get singleton instance of ImageLoader
        imageLoader = ImageLoader.getInstance();
    }

    public void setImageURLs(ArrayList<String> list){
        ListOfURLs = list;
        for(String str: ListOfURLs)
            Log.i("URL Address>>>>", str);

        cacheDir = new File(Environment.getExternalStorageDirectory(), "UniversalImageLoader/Cache");

        // Create configuration for ImageLoader
        config = new ImageLoaderConfiguration.Builder(context)
                    .maxImageWidthForMemoryCache(800)
                    .maxImageHeightForMemoryCache(800)
                    .httpConnectTimeout(5000)
                    .httpReadTimeout(30000)
                    .threadPoolSize(5)
                    .threadPriority(Thread.MIN_PRIORITY + 2)
                    .denyCacheImageMultipleSizesInMemory()
                    .memoryCache(new UsingFreqLimitedMemoryCache(2000000)) // You can pass your own memory cache implementation
                    .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
                    .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
                    .build();

        // Creates display image options for custom display task
        options = new DisplayImageOptions.Builder()
                    .showStubImage(R.drawable.icon_loading)
                    .showImageForEmptyUrl(R.drawable.icon_remove)
                    .cacheInMemory()
                    .cacheOnDisc()
                    .decodingType(DecodingType.MEMORY_SAVING)
                    .build();

        // Initialize ImageLoader with created configuration. Do it once.
        imageLoader.init(config);

    }

    @Override
    public int getCount() {
        return ListOfURLs.size();
    }

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

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

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

        if (convertView == null) {
            convertView = myInflater.inflate(R.layout.grid_contestantsphoto, null);
            holder = new ViewHolder();
            holder.ivIcon = (ImageView) convertView.findViewById(R.id.imvContestantsPhoto_icon);

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

//        holder.ivIcon.setImageBitmap(bitmapList[position]);

        String imageUrl = ListOfURLs.get(position);
        // Load and display image
        imageLoader.displayImage(imageUrl, holder.ivIcon, options, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted() {
                showLoading();
            }
            @Override
            public void onLoadingFailed() {
                stopLoading();
            }
            @Override
            public void onLoadingComplete() {
                stopLoading();
            }
        });

        return convertView;
    }   

    static class ViewHolder {
        ImageView ivIcon;
    }


    /*-----------------------------------------------------------------------------------
     *  Showing / Stopping progress dialog which is showing loading animation
     *  ---------------------------------------------------------------------------------*/
    private void showLoading(){
        progressBar = ProgressDialog.show(context, "", "");
        progressBar.setContentView(R.layout.anim_loading);
        progressBar.setCancelable(true);
        final ImageView imageView = (ImageView) progressBar.findViewById(R.id.blankImageView); 
        Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate);
        imageView.startAnimation(rotation); 
    }

    private void stopLoading() {        
        if(progressBar.isShowing())
            progressBar.dismiss();
    }

}

What I did?
1) I downloaded universal-image-loader-1.2.3.jar and put it into MY_PROJECT/lib folder then I added this jar file into java build path
enter image description here

2) Because for cashing images, this library needs to have access to local storage, therefore I added <uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE"/> to manifest file.

3) Now, when I run, the application crashes and points to imageLoader = ImageLoader.getInstance();. Logcat message is:

dalvikvm: Could not find class 'cam.astro.mania.adapters.ContestantsPhotoAdapter$1', referenced from method cam.astro.mania.adapters.ContestantsPhotoAdapter.getView
AndroidRuntime: java.lang.NoClassDefFoundError: com.nostra13.universalimageloader.core.ImageLoader
AndroidRuntime: at cam.astro.mania.adapters.ContestantsPhotoAdapter.<init>(ContestantsPhotoAdapter.java:50)

Based on my research (for example here), I found that this message “comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time.“

  • 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-06T02:58:42+00:00Added an answer on June 6, 2026 at 2:58 am

    When i remove jar file from Java class path and change the name of folder from “lib” to “libs”, then jar file automatically adds to Android Dependencies. Now, everything is fine

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

Sidebar

Related Questions

I my project I have an activity which has a grid view. This grid
I have a very simple web part. I have a single grid view, which
In my project I have an Xceed data grid which is bound to a
I have a scenario in my project I have a grid view and submit
ok i have a project which has many gridview in its pages... now i
I have a grid in a XAML file in a WPF project. This MainGrid
I have been developing a project and in this project i have designed my
I have some xaml code for a silverlight project sort of like below: <Grid>
I have project on recruitment.In this project, at one form I have a grid
I need to make a simple asp.net MVC project, which contains a GridView. 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.