我的RecyclerView是滞后的

时间:2016-01-11 23:37:28

标签: android android-recyclerview

我正在使用RecyclerView - CardView和volley用json获取mysql项目并在我的应用程序中显示,在每个cardview行我有一个垂直布局,在这个布局中我有4个水平布局与文本,

但是我的应用程序和滚动现在有点滞后,它适用于布局而且它们很多!

但我需要它们,我该怎么办?

public class CardAdapter extends RecyclerView.Adapter<CardAdapter.ViewHolder> {

//Imageloader to load image
private ImageLoader imageLoader;
private Context context;

//List to store all superheroes
List<Getter_Setter> superHeroes;

//Constructor of this class
public CardAdapter(List<Getter_Setter> superHeroes, Context context){
    super();
    //Getting all superheroes
    this.superHeroes = superHeroes;
    this.context = context;
}




@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.ads_list, parent, false);
    ViewHolder viewHolder = new ViewHolder(v);
    return viewHolder;
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {

    //Getting the particular item from the list
    Getter_Setter superHero =  superHeroes.get(position);

    //Loading image from url
    imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
    imageLoader.get(superHero.getImageUrl(), ImageLoader.getImageListener(holder.imageView, R.drawable.imageloader, android.R.drawable.ic_dialog_alert));

    //Showing data on the views
    holder.imageView.setImageUrl(superHero.getImageUrl(), imageLoader);
    holder.textViewName.setText(superHero.getName());
    holder.textView_MainBrand.setText(superHero.getBrand());

}

@Override
public int getItemCount() {
    return superHeroes.size();
}

class ViewHolder extends RecyclerView.ViewHolder{
    //Views
    public NetworkImageView imageView;
    public TextView textViewName;
    public TextView textView_MainBrand;

    //Initializing Views
    public ViewHolder(View itemView) {
        super(itemView);
        imageView = (NetworkImageView) itemView.findViewById(R.id.imageViewHero);
        textViewName = (TextView) itemView.findViewById(R.id.textViewName);
        textView_MainBrand = (TextView) itemView.findViewById(R.id.textView_MainBrand);
    }
}

}

My Applicatoin Picture...

0 个答案:

没有答案