I have this getView method inside my ListViewAdapter:
public static class ViewHolder{
public TextView textTitle;
public ImageView image;
}
public View getView(int position, View convertView, ViewGroup parent)
{
Project pro = getItem(position);
View vi=convertView;
ViewHolder holder;
if(convertView==null){
vi = inflater.inflate(R.layout.listitems, null);
holder=new ViewHolder();
holder.textTitle=(TextView)vi.findViewById(R.id.txt_title);;
holder.image=(ImageView)vi.findViewById(R.id.image);
vi.setTag(holder);
}
else
holder=(ViewHolder)vi.getTag();
holder.textTitle.setText(pro.project_title);
holder.image.setTag(pro);
imageLoader.DisplayImage(pro.smallImageUrl, activity, holder.image);
return vi;
}
since this is for a listview, it shows both images and text.
In the other hand I have an activity, where I want to apply the imageLoader.DisplayImage
method in it only to sh开发者_开发技巧ow images.
Based on the ListView Adapter, I made this inside an activity:
imageLazy(image1, Main.this, prjcts.get(randomIndex1));
public void imageLazy(final ImageView image, Activity activity, Project pro)
{
imageLoaderx.DisplayImage(pro.smallImageUrl, activity, image);
}
But then my app crashed. The Logcat reports a Nullpointer Exception Error and an error with my imageLazy method.
Can anybody help me to solve my problem? So that my method can display the images without error? Thank you very much
imageLoaderX has not been initialized and is null. You can fix this by creating a new object or getting a non null reference elsewhere.
精彩评论