title: Android popup window dismissal
body: <p>I have a popup window displaying when I click an item in my list activity. The problem is that the back key doesn't close it. I tried catching the back key in my list activity but it doesn't register it...then I tried registering a onkeylistener to the view I'm passing to my popup window. Like this:</p>
  
  <pre><code>pop.setOnKeyListener(new View.OnKeyListener() {
  
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
              // TODO Auto-generated method stub
              boolean res=false;
              if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; event.getRepeatCount() == 0) {
                  // do something on back.
                  Log.e("keydown","back");
                  if (pw.isShowing()) {
                      Log.e("keydown","pw showing");
                      pw.dismiss();
                      res = true;
                  }
              } else {
                  res = false;
              }
              return res;
          }
      });
  </code></pre>
  
  <p>which is passed to a popup like this: </p>
  
  <pre><code>pw = new PopupWindow(
         pop, 
         240, 
         70, 
         true);
  </code></pre>
  
  <p>But that listener doesn't fire neither. Can you help me? I'm out of ideas :)</p>