2017-02-24 68 views
0

我在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(); 
} 
} 
+0

使用方法跟踪,以确定你在哪里花你的时间。 – CommonsWare

+2

是什么让你认为这是回收商的观点? laggy行为不能与它可能花费大量时间来获取图像的事实相关联吗?如果你评论毕加索的电话,它是否仍然滞后? – Fred

+0

滚动不能落后 - 毕加索是异步的。你在别处做错了 –

回答

1

你有没有设置任何背景图片到你的活动。如果是,则检查背景图像的大小。可能是太大了。这可能会让它变得迟钝。

+0

没有背景图片。 – RandomyzeEverything