0
I have the following code to display images through URL
public class AdapterListPesquisaResp extends BaseAdapter {
private ImageLoader il;
private LayoutInflater mInflater;
private ArrayList<ItemListaPesquisaResp> itens;
Context context;
public AdapterListPesquisaResp(Context context, ArrayList<ItemListaPesquisaResp> itens) {
this.itens = itens;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return itens.size();
}
public ItemListaPesquisaResp getItem(int position) {
return itens.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View view, ViewGroup parent) {
ItemSuporte itemHolder;
if (view == null) {
view = mInflater.inflate(R.layout.texto_resposta_pesquisa, null);
itemHolder = new ItemSuporte();
itemHolder.txtTitle = ((TextView) view.findViewById(R.id.txtnome_resp_pesquisa));
itemHolder.txtTrabalho = ((TextView) view.findViewById(R.id.txttrabalho_resp_pesquisa));
itemHolder.txtkm = ((TextView) view.findViewById(R.id.txtkm_resp_pesquisa));
itemHolder.imgIcon = ((ImageView) view.findViewById(R.id.imagemviewfoto_resp_pesquisa));
itemHolder.imgnota = ((ImageView) view.findViewById(R.id.imageView_nota_estrela));
itemHolder.txtkminforma = ((TextView) view.findViewById(R.id.textView));
itemHolder.corfundo = ((RelativeLayout)view.findViewById(R.id.layoutresposta_pesquisa));
view.setTag(itemHolder);
} else {
itemHolder = (ItemSuporte) view.getTag();
}
ItemListaPesquisaResp item = itens.get(position);
if (item.toString() == "Anuncios de trabalho") {
itemHolder.txtTitle = ((TextView) view.findViewById(R.id.txtnome_resp_pesquisa));
} else {
if (item.getnome().equals("Buscar")) {
itemHolder.txtTrabalho.setVisibility(View.GONE);
itemHolder.txtkm.setVisibility(View.GONE);
itemHolder.imgIcon.setVisibility(View.GONE);
itemHolder.imgnota.setVisibility(View.GONE);
itemHolder.txtkminforma.setVisibility(View.GONE);
itemHolder.txtTitle.setText("Mais");
}
else {
itemHolder.txtTrabalho.setVisibility(View.VISIBLE);
itemHolder.txtkm.setVisibility(View.VISIBLE);
itemHolder.imgIcon.setVisibility(View.VISIBLE);
itemHolder.imgnota.setVisibility(View.VISIBLE);
itemHolder.txtkminforma.setVisibility(View.VISIBLE);
itemHolder.txtTitle.setText(item.getnome());
itemHolder.txtTrabalho.setText(item.getprofissao());
itemHolder.txtkm.setText(item.getkm());
itemHolder.txtkminforma.setText("km");
if (item.getfoto().equals("")) {
} else {
if (item.getfoto().equals(" ")){
}else {
Picasso.with(context).load(item.getfoto()).into(itemHolder.imgIcon); // esta dando erro aqui!
}
}
itemHolder.imgnota.setImageDrawable(item.getnota());
}
}
return view;
}
private class ItemSuporte {
ImageView imgnota, buscarimg,imgIcon;
TextView txtTitle, txtkminforma;
public TextView txtkm;
public TextView txtTrabalho;
TextView buscar;
RelativeLayout corfundo;
}
}
Whatever comes back to me on Logcat is
11-20 15:03:30.566 660-660/spac.com.br.jobbroker E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Context must not be null.
at com.squareup.picasso.Picasso$Builder.<init>(Picasso.java:635)
at com.squareup.picasso.Picasso.with(Picasso.java:597)
at spac.com.br.jobbroker.Pesquisa_subs.AdapterListPesquisaResp.getView(AdapterListPesquisaResp.java:111)
at android.widget.AbsListView.obtainView(AbsListView.java:2271)
at android.widget.ListView.makeAndAddView(ListView.java:1769)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillFromTop(ListView.java:733)
at android.widget.ListView.layoutChildren(ListView.java:1622)
at android.widget.AbsListView.onLayout(AbsListView.java:2106)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1868)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1689)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Puts I hadn’t even noticed! Thank you very much.
– Guilherme