Thank you Anas and Kumar,
I think the code was not working because of a mistake of using locale
variable .. before I discovered that I changed the code to use touch or long
touch .. here it is for any one who would like to do similar thing .. Please
make sure to make time variable global not locale.
switch (eventaction ) {
case MotionEvent.ACTION_DOWN:
time = event.getDownTime();
break;
case MotionEvent.ACTION_UP:
//Do action associated with touch
ret= true;
break;
case MotionEvent.ACTION_MOVE:
timediff = (event.getEventTime() - time);
if (timediff > 1000 ) // 1 Second
{
// Do action associated with long touch - 1 Sec
ret= true;
}
else ret= false;
break;
}
Best regards,
Waleed
On Thu, Oct 14, 2010 at 9:01 AM, AnasSamara <[email protected]> wrote:
> You have to catch the ACTION_DOWN to get a copy of the widget you
> touched using "getDrawingCache", and catch the ACTION_MOVE to set new
> location for the layout which holds the the drawing copy you already
> got from the ACTION_DOWN.
>
>
> On Oct 13, 8:26 pm, Kumar Bibek <[email protected]> wrote:
> > Hope this gives you an idea.
> http://techdroid.kbeanie.com/2010/04/simple-drag-n-drop-on-android.html
> >
> >
> >
> > On Tue, Oct 12, 2010 at 2:40 PM, Waleed Oransa <[email protected]>
> wrote:
> > > Hello all,
> >
> > > I need your help in differentiate between touch event and drag .. since
> I
> > > need to do action when user touch the screen and another action when it
> > > touch and drag .. I wrote the code below but it only works for touch
> but not
> > > for drag. ret is the return value of the onTouch method.
> >
> > > I appreciate if you can help or provide a code example. Thanks
> > > Waleed
> >
> > > switch (eventaction ) {
> > > case MotionEvent.ACTION_MOVE:
> > > moveTouch = true;
> > > ret=false;
> > > break;
> > > case MotionEvent.ACTION_DOWN:
> > > startTouch = true;
> > > ret=false;
> > > break;
> > > case MotionEvent.ACTION_UP:
> > > if (startTouch== true && moveTouch == false)
> > > {
> > > // Do action associated with touch
> > > ret= true;
> > > moveTouch = false;
> > > startTouch= false;
> > > }
> > > else if (startTouch= true && moveTouch == true)
> > > {
> > > // Do action associated with drag
> >
> > > ret= true;
> > > moveTouch = false;
> > > startTouch= false;
> > > }
> >
> > > break;
> > > }
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> > --
> > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en