Android newbie learning dialogs = CRASH
<p>I'm trying to learn custom dialogs.   I made one with a button in it and it comes up fine and I can hit breakpoints in the constructor and onCreate method, but when I click the button it crashes without ever getting to the button handler.  </p>

<p>The dialog layout XML (my_dialog_layout.xml) is:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"&gt;  
  &lt;Button
     android:id="@+id/AButton"
     android:layout_width="100px"
     android:layout_height="wrap_content"
     android:layout_alignParentRight="true"
     android:layout_marginLeft="10px"
     android:onClick="AButtonHandler"
     android:text="Click Me"
  /&gt; 
  &lt;TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_toLeftOf="@id/AButton"
    android:text="Click this button: " 
    /&gt; 
  /&gt;
</code></pre>

<p>... and the Dialog's java file is:  </p>

<pre><code>import android.os.Bundle;
import android.widget.Toast;
import android.view.View;
import android.content.Context; 
import android.app.Dialog;

public class MyDialog extends Dialog {

    public MyDialog(Context context) {
        super(context);
        setContentView(R.layout.my_dialog_layout);
   }

    public void AButtonHandler(View target) {
        int i = 0;   // just a placeholder to set a breakpoint at
        i++;         //   "                 "
//       Toast.makeText(this, "in AButtonHandler", Toast.LENGTH_LONG).show();
        MyDialog.this.dismiss();
    }

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
  //      Toast.makeText(this, "Dialog onCreate", Toast.LENGTH_LONG).show();
    }   
}
</code></pre>

<p>When I click AButton it crashes in the debugger before getting to my breakpoint in AButtonHandler with "
<em>Thread [&lt;1> main] (Suspended (exception IllegalStateException))<br>
    View$1.onClick(View) line: 2059 
    Button(View).performClick() line: 2408</em> 
..."</p>

<p>Also notice the commented-out Toast's.    I wanted to put Toasts in but thye compiler gives me:  <em>The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (MyDialog, 
 String, int)</em>     What am I doing wrong?</p>

<p>Thanks in advance!</p>
