我有一個問題,當我滾動我的列表視圖,圖像似乎繼續重新加載自己,它使得列表視圖滯後很多。 我能做些什麼來防止這種情況發生,我之前在我的listview中做過這件事,而且它沒有這樣做。畢加索圖像重新加載滾動在列表視圖
public class PostsAdapter extends BaseAdapter{
public List<PostList> postList;
protected Context context;
public void add(PostList object,int position) {
postList.add(position,object);
}
public PostsAdapter(Context context) {
this.context = context;
postList = new ArrayList<PostList>();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return postList.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return postList.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
if(convertView == null){
convertView = LayoutInflater.from(context).inflate(R.layout.posts_list, null);
holder = new ViewHolder();
holder.image = (ImageView)convertView.findViewById(R.id.postImage);
holder.username = (TextView)convertView.findViewById(R.id.postUsername);
convertView.setTag(holder);
}else{
holder = (ViewHolder)convertView.getTag();
}
holder.username.setText(postList.get(position).user);
Picasso.with(context).load(postList.get(position).postPicture).into(holder.image);
return convertView;
}
static class ViewHolder{
ImageView image;
TextView username;
}
加上'Picasso.with(上下文).load(postList.get(位置).postPicture).into(架.image);'in you'if(convertView == null){...}'從其他地方移除。 – Rustam 2014-10-22 06:02:35
public void add(PostList對象,int位置){ postList.add(position,object); }這就是爲什麼你使用 – 2014-10-22 06:04:26
public PostsAdapter(Context context,ArrayList List){ this.context = context; postList = List; }在適配器中使用此缺點 –
2014-10-22 06:05:20