2

Can anyone tell me the way how to drag a image form gallery view and drop that in a grid view in android. Is that possible. My requirement is, I have an image and I break them in to some pieces, by using custom adapter place all those images in a gallery view, now drag those images in the galley drop that on the grid view on the same screen. Below image can give clear picture to you. Provide me the way how to do that.enter image description here

user3285681
  • 230
  • 3
  • 12
  • Kindly go through http://stackoverflow.com/questions/10846240/drag-and-drop-images-in-gridview-in-android .hope you will get ur answer. – Ajit Kumar Apr 21 '14 at 10:08

1 Answers1

1

Can anyone tell me the way how to drag a image form gallery view and drop that in a grid view in android. Is that possible.

Yes that is possible. Use Android drag/drop framework that will allow your users to move data from one View to another View in the current layout using a graphical drag and drop gesture.

This example might help you.

Explanation :

When you drop the image to new location

  1. Remove that view form its parent (Galleryview in your case)
  2. Add that view to your new Parent (GridView in your case)
  3. Update the corresponding adapters with data.

eg.

     case DragEvent.ACTION_DROP:
          ViewGroup oldParent = (ViewGroup) view.getParent();
          oldParent.removeView(view);
          GridView container = (GridView) layoutview;
          container.addView(view);
          view.setVisibility(View.VISIBLE);
          break;
Ritesh Gune
  • 16,629
  • 6
  • 44
  • 72