title: MotionEvent and the touch detector?
body: <p>I want to ask a question:</p>
  
  <p>I used a MotionEvent code to drag a button for a question and answer game I'm working on it, the thing is that I can't click on the dragged button anymore after I start dragging it, it looks like it stays always in ACTION_DOWN, I tried the CANCEL and UP actions too, but still same thing!</p>
  
  <p>Also how can I make the dragged button do something when it touch another button or item (like i want it to detect the touch of the other items) like when the dragged button [btn1] touches another button [btn2] it will change the color for example!!</p>
  
  <p>3 problems: </p>
  
  <ul>
  <li><p>it wont get up </p></li>
  <li><p>you cant click on it anymore </p></li>
  <li><p>touch detect </p></li>
  </ul>
  
  <p>any suggestion how to fix that plz! and ty in advance </p>
  
  <pre><code>import android.app.*;
  import android.os.*;
  import android.view.*;
  import android.view.View.*;
  import android.widget.*;
  import android.content.*;
  import android.graphics.*;
  import android.media.*;
  import android.net.*;
  import android.text.*;
  import android.util.*;
  import android.webkit.*;
  import android.animation.*;
  import android.view.animation.*;
  import java.util.*;
  import java.text.*;
  import android.app.Activity;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.widget.Button;
  import java.util.Timer;
  import java.util.TimerTask;
  import android.view.View;
  
  
      public class MainActivity extends Activity {
  
          private Timer _timer = new Timer();
  
          private double res = 0;
          private double lvl = 0;
          private String message = "";
  
          private LinearLayout linear3;
          private TextView textview13;
          private LinearLayout linear11;
          private LinearLayout linear13;
          private LinearLayout linear12;
          private LinearLayout linear8;
          private Button button1;
          private TextView textview14;
          private Button button4;
          private Button button2;
          private Button button3;
  
          private TimerTask m;
          @Override
          protected void onCreate(Bundle _savedInstanceState) {
              super.onCreate(_savedInstanceState);
              setContentView(R.layout.main);
              initialize();
              initializeLogic();
          }
  
          private void initialize() {
  
              linear3 = (LinearLayout) findViewById(R.id.linear3);
              textview13 = (TextView) findViewById(R.id.textview13);
              linear11 = (LinearLayout) findViewById(R.id.linear11);
              linear13 = (LinearLayout) findViewById(R.id.linear13);
              linear12 = (LinearLayout) findViewById(R.id.linear12);
              linear8 = (LinearLayout) findViewById(R.id.linear8);
              button1 = (Button) findViewById(R.id.button1);
              textview14 = (TextView) findViewById(R.id.textview14);
              button4 = (Button) findViewById(R.id.button4);
              button2 = (Button) findViewById(R.id.button2);
              button3 = (Button) findViewById(R.id.button3);
  
              button1.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      button1.setOnTouchListener(new OnTouchListener() {
                          PointF DownPT = new PointF();
                          PointF StartPT = new PointF();
                          @Override public boolean onTouch(View v, MotionEvent event) {
                              int eid = event.getAction();
                              switch (eid) {
                                  case MotionEvent.ACTION_MOVE:PointF mv = new PointF(event.getX() - DownPT.x, event.getY() - DownPT.y);
                                  button1.setX((int)(StartPT.x+mv.x));
                                  button1.setY((int)(StartPT.y+mv.y));
                                  StartPT = new PointF(button1.getX(), button1.getY());
                                  break;
                                  case MotionEvent.ACTION_DOWN : DownPT.x = event.getX();
                                  DownPT.y = event.getY();
                                  StartPT = new PointF(button1.getX(), button1.getY());
                                  break;
                                  case MotionEvent.ACTION_UP :
                                  break;
                                  default : break;
                              }
                              return true;
                          }
                      });
                      textview13.setText(message);
                  }
              });
  
              button4.setOnClickListener(new View.OnClickListener() {
                  @Override
  public void onClick(View view) {
  
              }
          });
  
          button2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  button1.setBackgroundColor(0xFFCFD8DC);
              }
          });
  
          button3.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
              }
          });
      }
      private void initializeLogic() {
          /**
  android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); 
  gd.setCornerRadius(30);**/
           /* radius */
          /*gd.setStroke(4, Color.WHITE);*/
           /* stroke heigth and color */
  
          m = new TimerTask() {
              @Override
              public void run() {
                  runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                          lvl = 1;
                          textview14.setText("من هو مستر صلصا ؟");
                          button2.setText("مدير قناة صلصا");
                          button3.setText("صاحب سلسلة \nألف ليلة و ليلة");
                          button4.setText("لا أعلم");
                      }
                  });
              }
          };
          _timer.schedule(m, (int)(1000));
          m = new TimerTask() {
              @Override
              public void run() {
                  runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                          if ((((SketchwareUtil.getLocationX(button1) + 75) &gt; (SketchwareUtil.getLocationX(button2) - 120)) &amp;&amp; ((SketchwareUtil.getLocationX(button1) - 125) &lt; (SketchwareUtil.getLocationX(button2) + 120))) &amp;&amp; (((SketchwareUtil.getLocationY(button1) + 130) &gt; (SketchwareUtil.getLocationY(button2) - 60)) &amp;&amp; ((SketchwareUtil.getLocationY(button1) - 70) &lt; (SketchwareUtil.getLocationY(button2) + 60)))) {
                              res = 1;
                              button2.setBackgroundColor(0xFF64DD17);
                          }
                          if ((((SketchwareUtil.getLocationX(button1) + 75) &gt; (SketchwareUtil.getLocationX(button3) - 120)) &amp;&amp; ((SketchwareUtil.getLocationX(button1) - 125) &lt; (SketchwareUtil.getLocationX(button3) + 120))) &amp;&amp; (((SketchwareUtil.getLocationY(button1) + 130) &gt; (SketchwareUtil.getLocationY(button3) - 60)) &amp;&amp; ((SketchwareUtil.getLocationY(button1) - 70) &lt; (SketchwareUtil.getLocationY(button3) + 60)))) {
                              res = 2;
                              button3.setBackgroundColor(0xFFF44336);
                          }
                          if ((((SketchwareUtil.getLocationX(button1) + 75) &gt; (SketchwareUtil.getLocationX(button4) - 120)) &amp;&amp; ((SketchwareUtil.getLocationX(button1) - 125) &lt; (SketchwareUtil.getLocationX(button4) + 120))) &amp;&amp; (((SketchwareUtil.getLocationY(button1) + 130) &gt; (SketchwareUtil.getLocationY(button4) - 60)) &amp;&amp; ((SketchwareUtil.getLocationY(button1) - 70) &lt; (SketchwareUtil.getLocationY(button4) + 60)))) {
                              res = 3;
                              button4.setBackgroundColor(0xFFF44336);
                          }
                      }
                  });
              }
          };
          _timer.scheduleAtFixedRate(m, (int)(1000), (int)(100));
      }
  
      @Override
      protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) {
          super.onActivityResult(_requestCode, _resultCode, _data);
  
          switch (_requestCode) {
  
              default:
              break;
          }
      }
  </code></pre>