我想實現我getView觀點持有者()方法,但是,它墜毀並顯示在視圖持有人所有這些觀點是空的,爲什麼,這裏是我的代碼。空指針異常列表視圖適配器使用視圖架時
if(view==null){
viewHolder=new ViewHolder();
view=inflater.inflate(R.layout.find_new_thing_item,null);
viewHolder.progressBar=(ProgressBar)view.findViewById(R.id.find_new_thing_item_progress_bar);
viewHolder.mainPictureImageView=(ImageView)view.findViewById(R.id.find_new_thing_item_main_image);
viewHolder.userIconImageView=(ImageView)view.findViewById(R.id.find_new_thing_item_user_icon);
viewHolder.thingsNameTextView=(TextView)view.findViewById(R.id.find_new_thing_item_name);
viewHolder.priceTextView=(TextView)view.findViewById(R.id.find_new_thing_item_price);
viewHolder.userNameTextView=(TextView)view.findViewById(R.id.find_new_thing_item_user_name);
viewHolder.userCommentTextView=(TextView)view.findViewById(R.id.find_new_thing_item_user_comment);
viewHolder. numberOfLikesTextView=(TextView)view.findViewById(R.id.find_new_thing_item_number_of_likes);
viewHolder.numberOfAddToDouListTextView=(TextView)view.findViewById(R.id.find_new_thing_item_number_of_add_to_dou_list);
viewHolder.numberOfReplyTextView=(TextView)view.findViewById(R.id.find_new_thing_item_number_of_reply);
view.setTag(viewHolder);
}else {
viewHolder=(ViewHolder)view.getTag();
}
new DownloadItemImage().execute(thingsItemArrayList.get(i-1).getMainPicture());
new DownloadUserIcon().execute(thingsItemArrayList.get(i-1).getUserIcon());
viewHolder.thingsNameTextView.setText(thingsItemArrayList.get(i - 1).getThingsName());
viewHolder.priceTextView.setText(thingsItemArrayList.get(i-1).getPrice());
viewHolder.userNameTextView.setText(thingsItemArrayList.get(i-1).getUserName());
viewHolder.userCommentTextView.setText(thingsItemArrayList.get(i-1).getUserComment());
viewHolder.numberOfLikesTextView.setText(thingsItemArrayList.get(i-1).getNumberOfLikes());
viewHolder.numberOfAddToDouListTextView.setText(thingsItemArrayList.get(i-1).getNumberOfAddToDouList());
if(thingsItemArrayList.get(i-1).getNumberOfReply().indexOf("評論")>=0){
viewHolder.numberOfReplyTextView.setText(thingsItemArrayList.get(i-1).getNumberOfReply());
}else{
viewHolder.numberOfReplyTextView.setText("評論 0");
}
return view;
請出示你r異常消息,所以我們可以幫助你。至少,它有一條線,你可以從它開始。 – joao2fast4u 2014-11-25 01:34:28
郵政錯誤的logcat – 2014-11-25 05:20:31