I have an error in logcat
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
Trying to view a picture in the list make a class for this code i think the error in the method View getView but i do not know where it is exactly i think may be here in the definition of thumbNail
public class useradaptor extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private List<user> userItems;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public useradaptor(Activity activity, List<user> userItems) {
this.activity = activity;
this.userItems = userItems;
}
@Override
public int getCount() {
return userItems.size();
}
@Override
public Object getItem(int location) {
return userItems.get(location);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
user u = userItems.get(position);
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbNail = (NetworkImageView) convertView.findViewById(R.id.imageview);
thumbNail.setImageUrl(u.getPicture(), imageLoader);
Cache cache = AppController.getInstance().getRequestQueue().getCache();
Cache.Entry entry = cache.get(u.getPicture());
if(entry != null){
try {
String data = new String(entry.data, "UTF-8");
// handle data, like converting it to xml, json, bitmap etc.,
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}else{
// cached response doesn't exists. Make a network call here
}
return convertView;
}
}