title: Displaying AlertDialog inside a Custom ListAdapter Class
body: <p>I am having a hard time dealing with displaying a <code>AlertDialog</code> inside a Custom <code>ListView</code> class which extends a <code>BaseAdapter</code>. </p>
  
  <pre><code>AlertDialog.Builder alertbox = new AlertDialog.Builder(getParent().getApplicationContext());
          alertbox.setMessage("No Internet Connection");
          alertbox.setTitle("Warning");
          alertbox.setIcon(R.drawable.trn_03);
  
          alertbox.setNeutralButton("OK",
                  new DialogInterface.OnClickListener() {
  
                      public void onClick(DialogInterface arg0,
                              int arg1) {
  
                      }
                  });
    alertbox.show();
  </code></pre>
  
  <p>The above is the code I am using, and the <code>LogCat</code> error is,</p>
  
  <pre><code>06-16 11:33:25.686: ERROR/AndroidRuntime(690): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
  </code></pre>
  
  <p>I believe that the problem is because of the context. I tried a few alternative. But none works. Can anyone help me in this?. </p>