0

I have two GridViews, in two separate fragments in my application. I would like to be able to 'add' items via tap from one GridView (already populated) into my empty grid view. How would I go about doing this?

ex. Shopping Cart, adding items from Products GridView into Inventory GridView

Evan Bashir
  • 5,501
  • 2
  • 25
  • 29

1 Answers1

1

You would start by having two separate Adapters for each GridView (with a way to access both from inside each Adapter).

When an item is clicked in Grid 1, Grid 1's Adapter should pass the Object at data.get(position) to a method in Grid 2's Adapter. That method should call add() or remove() depending on whatever logic you implement.

After passing the Object, you can remove it from Grid 1's Adapter if necessary.

Cruceo
  • 6,763
  • 2
  • 31
  • 52
  • Thanks for the fast reply, could you please go into a little more detail? I already have my two adapters set up. Just not quite sure how to create the OnClick. Don't need to remove objects after they've been tapped. – Evan Bashir Sep 06 '13 at 17:43
  • Add an OnItemClickListener or set the specific view with an OnClickListener within the Adapter. See: http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html – Cruceo Sep 06 '13 at 18:37