-1

public class CartAdapter extends RecyclerView.Adapter {

private Cursor mCursor;
private Context mContext;



public CartAdapter(Context mContext)
{ this.mContext = mContext;}

@NonNull
@Override
public CartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.cart_item,parent,false);

    return new CartViewHolder(view);
}

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

    int image = mCursor.getColumnIndex("image");
    int text1 = mCursor.getColumnIndex("title");
    int text2 = mCursor.getColumnIndex("amount");
   mCursor.moveToPosition(position);

   String name = mCursor.getString(text1);
    String name1 = mCursor.getString(text2);
    String image1 = mCursor.getString(image);

    holder.tt1.setText(name);
    holder.tt2.setText(name1);



    Glide.with(mContext)
            .asBitmap()
            .load(image1)
            .into(holder.imageview);



}

@Override
public int getItemCount() {
    if (mCursor == null){
    return 0;}
    return mCursor.getCount();
}


public class CartViewHolder extends RecyclerView.ViewHolder {

    TextView tt1,tt2,tt3;
    ImageView imageview;

    public CartViewHolder(View itemView) {
        super(itemView);

        tt1 = itemView.findViewById(R.id.quantitycart);
        tt2 = itemView.findViewById(R.id.pricecart);
        imageview = itemView.findViewById(R.id.cartImage);

    }
}

}

closed as off-topic by Firelord Jan 12 at 8:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about writing and publishing Android apps, writing custom ROMs, and other topics that are primarily of concern to developers are off-topic. Consider taking advantage of other resources that may be appropriate for your question." – Firelord
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.