有一个列表视图,我在运行时获取图像。使用毕加索库完成图像的提取。
但是每次我滚动,图像都会被填满。 我不知道是什么问题。请帮助。 代码如下。
public class example {
int n= 7;
public static void main (String[] args){
System.out.println(" the number here is "+ n);}}
}
答案 0 :(得分:0)
这是ListView的一个问题。我强烈建议您使用recyclerview。尝试;
public class FeedAdapter
extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
private Context context;
private final List<Feed> feedList;
public FeedAdapter(Context context, List<Feed> feeds) {
this.context = context;
this.feedList = feeds;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.feed_list_item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = feedList.get(position);
if (holder.mItem.getImageStatus().equals("1"))
Picasso.with(context).load(holder.mItem.getQuestionId()).into(holder.something);
else{
////
}
}
@Override
public int getItemCount() {
return feedList.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public final View view;
@BindView(R.id.something)
ImageView something;
Feed mItem;
ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
this.view = view;
}
}
}