-2
我在logcat的錯誤調用虛擬方法android.view.View android.view.View.findViewById(int)的'嘗試上的空對象引用
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
嘗試查看在一個畫面列表中進行類此代碼 我認爲在方法查看getView的錯誤,但我不知道它在哪裏正是我想可能是這裏的縮略圖
的定義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;
}
}