How to handle button click inside recycler view item in Xamarin Android?

HarshitaHarshita INMember ✭✭✭✭
edited September 10 in Xamarin.Android

here is the item inside recycler view,so I want to increase and decrease the quantity by clicking plus and minus button.How to do this in xamarin android?

here is my adapter

public class OrderDetailsItemAdapter : RecyclerView.Adapter
    List<OrderItem> orderItemList = new List<OrderItem>();
    RecyclerView orderItemsRecyclerView;
    private object orderListitems;
    private RecyclerView recyclerview;
    Context _context;

    public OrderDetailsItemAdapter(List<OrderItem> orderItemList, RecyclerView recyclerview,Context context)
        this.orderItemList = orderItemList;
        this.recyclerview = recyclerview;
        _context = context;

    public override int ItemCount
            return orderItemList.Count;

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        OrderDetailsItemViewHolder viewHolder = holder as OrderDetailsItemViewHolder;

        viewHolder.OrderItemCheckBox.Checked = orderItemList[position].IsChecked;
        viewHolder.OrderItemSKU.Text = $"SKU: {orderItemList[position].SKU}";
        viewHolder.KitIcon.Visibility = orderItemList[position].IsKit ? ViewStates.Visible : ViewStates.Invisible;
        viewHolder.OrderItemKitSKU.Text = $"KIT SKU: {orderItemList[position].KitSKU}";
        viewHolder.OrderItemQty.Text = $"REQ QTY: {orderItemList[position].OrderQuantity.ToString()}";

        viewHolder.OrderItemShipQty.Text = orderItemList[position].ShipQuantity.ToString();

    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        LayoutInflater inflater = LayoutInflater.From(parent.Context);
        View itemView = inflater.Inflate(Resource.Layout.order_details_layout_view, parent, false);
        return new OrderDetailsItemViewHolder(itemView);

so how to get the position of the item on button click?

Best Answer


  • HarshitaHarshita INMember ✭✭✭✭

    Thanks a lot. :)

Sign In or Register to comment.