我在RecyclerView其中包含图像和标题8个项目。 表现非常滞后。RecyclerView是laggy
我加载使用毕加索图像。图像甚至不是高分辨率导致滞后。
这里是我的适配器:
public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.CategoryViewHolder> {
private Context context;
private List<Category> categories;
class CategoryViewHolder extends RecyclerView.ViewHolder {
TextView categoryTitle;
ImageView categoryImage;
CategoryViewHolder(View view) {
super(view);
categoryTitle = (TextView) view.findViewById(R.id.category_title);
categoryImage = (ImageView) view.findViewById(R.id.category_thumbnail);
}
}
public CategoryAdapter(Context context, List<Category> categories) {
this.context = context;
this.categories = categories;
}
@Override
public CategoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.category_item, parent, false);
return new CategoryAdapter.CategoryViewHolder(itemView);
}
@Override
public void onBindViewHolder(final CategoryViewHolder holder, int position) {
Category category = categories.get(position);
holder.categoryTitle.setText(category.getCategoryTitle());
Picasso.with(context)
.load(category.getCategoryImage())
.into(holder.categoryImage);
}
@Override
public int getItemCount() {
return categories.size();
}
}
使用方法跟踪,以确定你在哪里花你的时间。 – CommonsWare
是什么让你认为这是回收商的观点? laggy行为不能与它可能花费大量时间来获取图像的事实相关联吗?如果你评论毕加索的电话,它是否仍然滞后? – Fred
滚动不能落后 - 毕加索是异步的。你在别处做错了 –