我在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
滾動不能落後 - 畢加索是異步的。你在別處做錯了 –