android - gridview item animation after action drop -


i m new android , per requirement implementing drag , drop on gridview achieve swap operation thing working fine , interchanging item within gridview had done far:- implement touchlistner imageview in adapter class

here-

holder.disp_imgview.setontouchlistener(new mytouchlistener(mcontext)); 

holder inner class adapter class , mytouchlistner class touch event.

here -

public final class mytouchlistener  implements ontouchlistener {  public boolean ontouch(view view, motionevent motionevent) {         // todo auto-generated method stub         if (motionevent.getaction() == motionevent.action_down) {             clipdata data = clipdata.newplaintext("", "");             vb=(vibrator) mcontext.getsystemservice(context.vibrator_service);             vb.vibrate(100);             dragshadowbuilder shadowbuilder = new view.dragshadowbuilder(view);             view.startdrag(data, shadowbuilder, view, 0);             view.setvisibility(view.visible);             view_position=view.getid();             first_image_view=view;              log.v("image touch", "clicked");             return true; } 

where dragshadowbuilder shadowbuilder creating shadow specific image touched user , starting dragging view.startdrag(data, shadowbuilder, view, 0);

next implement drag event imageview in adapter class

here-

holder.disp_imgview.setondraglistener(new mydraglistener());  class mydraglistener implements ondraglistener         {              @override             public boolean ondrag(view v, dragevent event) {                 // todo auto-generated method stub                 sec_view_id=v.getid();                  first_view_id=mytouchlistener.view_position;                   switch(event.getaction())                 {                 case dragevent.action_drag_started:                      log.e("action", "drag_started");                      break;                 case dragevent.action_drag_entered:                     v.setbackgrounddrawable(entershape);                      log.e("action", "drag_entered");                     break;                 case dragevent.action_drag_location:                     log.e("action", "drag_entered");                     break;                 case dragevent.action_drop:                      if(first_view_id!=sec_view_id)                     {                         integer temp=my_image_list.get(first_view_id);                         integer temp_sec=my_image_list.get(sec_view_id);                         my_image_list.set(first_view_id, temp_sec);                         my_image_list.set(sec_view_id, temp);                         image_adapter.notifydatasetchanged();                     }                     else                     {                     toast.maketext(mcontext, "can't place same image", 0).show();                        }                     log.e("action", "action_drop");                     break;                 case dragevent.action_drag_ended:                     log.e("action", "drag_ended");                     v.setbackgrounddrawable(normalshape);                 break;                 case dragevent.action_drag_exited:                     log.e("action", "drag_exited");                     break;                  }                  return true;             }          } 

as u can see on action drop swapping image in arraylist (my_image_list) , after notify adapter reflect change , working fine question

how can animation on second item move first item position in gridview , animation occur after action drop.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -