Universal Image Loader error loading image

Asked

Viewed 173 times

0

I want to upload images from the URL with the universal image:

java.lang.Noclassdeffounderror: com.nostra13.universalimageloader.core.Imageloaderconfiguration$Builder

I already downloaded the lib, and set up.

My Adapter:

  public class AdapterEmpresa extends BaseAdapter {

    private LayoutInflater mInflater;
    private List<Segmento> itens;

    ImageLoader imageLoader;
    DisplayImageOptions options;

    public AdapterEmpresa(Context context, List<Segmento> itensEmpresa) {
        //Itens que preencheram o listview
        super();
        this.itens = itensEmpresa;

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).build();
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        options = new DisplayImageOptions.Builder()
        .cacheInMemory()
        .cacheOnDisc()
        .build();
        //responsavel por pegar o Layout do item.
        mInflater = LayoutInflater.from(context);
    }



    /**
     * Retorna a quantidade de itens
     * 
     * @return
     */
    public int getCount() {
        return itens.size();
    }

    /**
     * Retorna o item de acordo com a posicao dele na tela.
     *
     * @param position
     * @return
     */
    public Segmento getItem(int position) {
        return itens.get(position);
    }

    /**
     * Sem implementação
     *
     * @param position
     * @return
     */

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

    public View getView(int position, View view, ViewGroup parent) {
        //Pega o item de acordo com a posção.
        LinearLayout row = (LinearLayout)view;
        Segmento item = itens.get(position);
        //infla o layout para podermos preencher os dados
        view = mInflater.inflate(R.layout.empresa_item, null);
        //atravez do layout pego pelo LayoutInflater, pegamos cada id relacionado
        //ao item e definimos as informações.
        final ImageView iconImg = (ImageView)row.findViewById(R.id.imagemSegmento);
        TextView nome = (TextView)row.findViewById(R.id.nomeEmpresa);
        TextView subtitulo = (TextView)row.findViewById(R.id.subtitulo);
        final ProgressBar indicator = (ProgressBar)row.findViewById(R.id.progress);

        indicator.setVisibility(View.VISIBLE);
        iconImg.setVisibility(View.INVISIBLE);


        ImageLoadingListener listener = new ImageLoadingListener(){

            @Override
            public void onLoadingCancelled(String arg0, View arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
                indicator.setVisibility(View.INVISIBLE);
                iconImg.setVisibility(View.VISIBLE);
            }

            @Override
            public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onLoadingStarted(String arg0, View arg1) {
                // TODO Auto-generated method stub

            }
        };
        imageLoader.displayImage(getItem(position).getImagem(), iconImg,options, listener);
      //Set the relavent text in our TextViews
      nome.setText(getItem(position).getNome());
      subtitulo.setText(getItem(position).getSubtitulo());
      return row;


}

I’m calling the Adapter like this:

adapterEmpresa = new AdapterEmpresa(EmpresaView.this, itensEmpresa);

passing only the list, because the image string is already in the list.

Does anyone know what it can be?

  • Put the jar in the folder libs of your project or just added to your Buildpath? You’re using the Eclipse?

  • only in Buildpath, yes eclipse

  • Then you need to include this jar in the libs folder at the root of your project. Otherwise it won’t be included in apk, causing this problem.

  • now from nullPointException, know what can be?

  • could solve, it was because I put Linearlayout there in the code, and the correct one was relative, vlw

1 answer

0


To fix the problem of missing class in the Classpath you need to include the jar of the library in the folder libs at the root of your project. It is automatically included in your project’s classpath.

With that, when generating the apk, the library will be packaged together and all classes will go to the application classpath.

The problem is that just adding the library to the classpath is not the correct one, and the classes in this library do not go to the application on deploy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.