add a custom object from position onclick to a custom arraylist

This worked!

   mAdapter.setOnItemClickListener(new MainAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Inventory item = inventoryList.get(position);
                String name = item.getName();
                String code = item.getCode();
                cartList.add(new Inventory(code, name, 0.00, 1 ));
            }
        });
    }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top