title: how to set an OnTouchListener for a PopupWindow?
body: <p>Here's my code that shows a PopUp when the button is touched and dismisses it, when the user releases his finger.</p>
  
  <p>But I need to know weather the user had just released his finger or did he slide into the popup and release his finger from there.</p>
  
  <p>In my code this doesn't really work, since I guess the popup doesn't get focus without the user releasing his finger. Is there a way to fix it?</p>
  
  <p>Thanks!</p>
  
  <pre><code>    LinearLayout LinLay = new LinearLayout(this);
      ImageView ivg = new ImageView(this);
      ivg.setImageResource(R.drawable.icon);
      LinLay.addView(ivg);
      final PopupWindow pw = new PopupWindow(LinLay, 100, 100, true);
  
      final Button bt2 = (Button)findViewById(R.id.button2);
      bt2.setOnTouchListener(new OnTouchListener(){
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              if(event.getAction() == MotionEvent.ACTION_DOWN )
                  {
                  pw.showAtLocation(bt2, Gravity.CENTER, 0, 0); 
                  }
              else if(event.getAction() == MotionEvent.ACTION_UP )
                  {
                  pw.dismiss();
                  }
              return true;
          }
          });
  
  
      ivg.setOnTouchListener(new OnTouchListener(){
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              if(event.getAction() == MotionEvent.ACTION_UP )
                  {
                  showToast(); /// doesn't work! :)
                  }
              return true;
          }
          });
      }
  
  
  public void showToast()
  {
      Toast.makeText(this, "AAA!", 500).show();
  }
  </code></pre>