Добавить элемент из пользовательской коллекции в другую коллекцию по щелчку - Ява
I am working on a simple shopping cart project. Currently, trying to add custom items via onClick from one RecyclerView and have it added to a new seperate ArrayList that will show in the cart RecyclerView. I'm able to add new blank custom objects to the ArrayList but can't seem to figure out how to add the selected item. I tried passing position through a couple of parts none working. Here is the code: <pre> mAdapter.setOnItemClickListener(new MainAdapter.OnItemClickListener() { @Override public void onItemClick(int position) { addToCart(position); } }); } public void addToCart(int position){ cartList.add(new Inventory()); }
Что я уже пробовал:
Я попробовал вставить позицию в add().