I want to load images from Url with universal image loader, but the error:
java.lang.NoClassDefFoundError: com.nostra13.universalimageloader.core.ImageLoaderConfiguration $ Builder
I've already downloaded the lib, and set it 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);
just passing the list, because the Image String is already in the list.
Does anyone know what it can be?