title: Handling back-key in custom view of a dialog
body: <p>Okay so I have a custom view inside a dialog but its onKeyDown never get called. I tried onKeyPreIme too but didn't work and setting dialog's setCancelable to true didn't help either.</p>
  
  <p>edit : </p>
  
  <pre><code>//Removed all unnecessary code
  
  public class CustomView extends LinearLayout
  {    
  
      @Override
      public boolean onKeyDown (int keyCode, KeyEvent event)
      {
              if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; event.getRepeatCount() == 0)
              {           
                     //do stuff here
                      return true;
  
              }    
              return super.onKeyDown(keyCode, event);         
      }
  }
  public class CustomDialog
  {
      Dialog dialog;
      public class CustomDialog(Context context)
      {
           dialog = new Dialog(context);
           dialog.setContentView(R.layout.test);// the test.xml has CustomView
  
      }
  
  }
  </code></pre>