hi

Can you please illustrate the scenarios of the constants
ACTION_MOVE,ACTION_DOWN,ACTION_UP ?

regards
Kaushik

On Fri, Jan 9, 2009 at 6:22 PM, Peli <peli0...@googlemail.com> wrote:

>
> what you have to do is, remember the coordinates that you get with the
> ACTION_DOWN event.
>
> Remember the distance (difference) between those coordinates and the
> original coordinates of your image (call that offsetX and offsetY),
> and subsequently in ACTION_MOVE always add those offset values.
>
> Peli
>
> On Jan 9, 11:36 am, "kaushik sur" <kaushik....@gmail.com> wrote:
> > Hi Peli
> >
> > here i attach my code, to be added , i have ressolved the issue of double
> > image by getting rawX() value of the event , and setting my absolute
> layout
> > according to that.
> > but here i get a unique problem, whenever i click the button and try to
> drag
> > it, the mouse tip comes to a certain pixels above from the topleft corner
> of
> > the button,like a offset distance,if you run the code on the emulator u
> wil
> > find this problem.
> > can anyone help to solve this?
> >
> > package com.google.android.samples.view.draganddrop;
> >
> > import android.app.Activity;
> > import android.content.Context;
> > import android.graphics.Canvas;
> > import android.os.Bundle;
> > import android.view.MotionEvent ;
> > import android.view.View;
> > import android.view.View.OnClickListener;
> > import android.widget.AbsoluteLayout;
> > import android.widget.Button;
> > import android.widget.Toast;
> >
> > public class Drag_And_Drop extends Activity {
> >  /** Called when the activity is first created. */
> >
> >  @Override
> >  public void onCreate(Bundle icicle) {
> >   super.onCreate(icicle);
> >
> >   MyView tx = new MyView(this);
> >   tx.setText("Drag Me");
> >   AbsoluteLayout l = new AbsoluteLayout(this);
> >
> >   AbsoluteLayout.LayoutParams p = new AbsoluteLayout.LayoutParams(
> >     AbsoluteLayout.LayoutParams.WRAP_CONTENT,
> >     AbsoluteLayout.LayoutParams.WRAP_CONTENT,10,10);
> >   l.addView(tx,p);
> >   setContentView(l);
> >
> >  }
> >
> >  class MyView extends Button
> >  {
> >   public MyView(Context c){
> >    super(c);
> >
> >   }
> >
> >   @Override
> >   public boolean dispatchTouchEvent(MotionEvent event) {
> >    int    mCurX=(int)event.getRawX();
> >    int mCurY=(int)event.getRawY();;
> >    System.out.println("scrollx "+this.getScrollX());
> >    int action = event.getAction();
> >    if ( action == MotionEvent.ACTION_MOVE ) {
> >     System.out.println("X="+mCurX+"  y="+mCurY);
> >     this.setText("x: " + mCurX + ",y: " + mCurY );
> >     AbsoluteLayout.LayoutParams p = new
> >     AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT,
> >       AbsoluteLayout.LayoutParams.WRAP_CONTENT,this.getScrollX()+ mCurX,
> >       this.getScrollY()+mCurY);
> >     this.setLayoutParams (p);
> >
> >    }
> >    return true;
> >   }
> >
> >   @Override
> >   public void draw(Canvas canvas) {
> >    // TODO Auto-generated method stub
> >    super.draw(canvas);
> >
> >   }
> >
> >  }
> >
> > }
> >
> > #####main.xml#####
> >
> > <?xml version=*"1.0"* encoding=*"utf-8"*?>
> >
> > <LinearLayout xmlns:android=*"http://schemas.android.com/apk/res/android
> "
> > *
> >
> > android:orientation=*"vertical"
> > *
> >
> > android:layout_width=*"fill_parent"
> > *
> >
> > android:layout_height=*"fill_parent"
> > *
> >
> >
> >
> > <TextView
> >
> > android:layout_width=*"fill_parent"*
> >
> > android:layout_height=*"wrap_content"*
> >
> > android:text=*"@string/hello"
> > *
> >
> > />
> >
> > <Button
> >
> > android:id=*"@+id/button"
> > *
> >
> > android:layout_width=*"fill_parent"
> > *
> >
> > android:layout_height=*"wrap_content"
> > *
> >
> > android:text=*"start transfer"
> > *
> >
> > />
> >
> > </LinearLayout>
> >
> > regards
> > Kaushik
> >
>  > On Thu, Jan 8, 2009 at 11:23 PM, Dan Raaka <micromys...@gmail.com>
> wrote:
> >
> > > Refer Launcher code in the source tree.
> >
> > > -M
> >
> > > On Jan 8, 8:13 am, "kaushik.siso" <kaushik....@gmail.com> wrote:
> > > > hi
> >
> > > > i want to know how can i enbale Drag and drop feature in android.
> > > > suppose i have a image,which are to be dragged and dropped on another
> > > > result and it will start a new activity.
> > > > i seek your help to  get a head-start atleast.
> >
> > > > regards
> > > > k...@sis
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to