I'm using RecyclerView
listview to show some list values.In this list I have two ImageView
and one Textview
. When I quickly scroll the list, app gets crashed. It's happened on some devices.Some devices it's worked but not smoothly scroll.
This is my adapter
public class MYAdapter extends RecyclerView.Adapter<MYAdapter.ItemViewHolder> {
private ArrayList<Data_Model> mItems;
private ClickListener clicklistener = null;
private Context context;
public RVAdapter(Context context,ArrayList<Data_Model> arrayList) {
this.context = context;
this.mItems = arrayList;
}
public class ItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView mTextView;
private ImageView imageview;
private ImageView mType;
public ItemViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
mTextView = (TextView) itemView.findViewById(R.id.list_item);
imageview = (ImageView) itemView.findViewById(R.id.image);
mType = (ImageView) itemView.findViewById(R.id.mtype);
}
@Override
public void onClick(View v) {
if (clicklistener != null) {
clicklistener.itemClicked(v, getAdapterPosition());
}
}
}
public void setClickListener(ClickListener listener) {
this.clicklistener = listener;
}
@Override
public void onBindViewHolder(ItemViewHolder itemViewHolder, int i) {
itemViewHolder.mTextView.setText(mItems.get(i).getTitle());
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(mItems.get(i).getImage(),bmOptions);
itemViewHolder.imageview.setImageBitmap(bitmap);
{
Bitmap bitmaps = BitmapFactory.decodeResource(context.getResources(),R.drawable.music);
itemViewHolder.mType.setImageBitmap(bitmaps);
}
@Override
public ItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_row, viewGroup, false);
ItemViewHolder itemViewHolder = new ItemViewHolder(view);
return itemViewHolder;
}
@Override
public int getItemCount() {
return mItems.size();
}
}
this is my list
Error Message