title: How do I get a simple alert on a button click?
body: <p>I was playing around with a simple app and I want to show an alert when a button is clicked.</p>
  
  <p>The code I have so far is: </p>
  
  <pre><code>package max.helloworld.firstapp;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.DialogInterface.OnClickListener;
  
  public class HelloWorldActivity extends Activity {
  /** Called when the activity is first created. */
  
  private Button closeButton;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      this.setContentView(R.layout.main);
      this.closeButton = (Button)this.findViewById(R.id.close);
      this.closeButton.setKeyListener(new onClickListener() {
          @Override
          public void onClick(View v) { 
              AlertDialog alertDialog = new AlertDialog.Builder(this).create();               
              alertDialog.setTitle("Transformers");
              alertDialog.setMessage("Optimus Prime");
              alertDialog.setButton("OK", new OnClickListener(){
                  public void onClick(DialogInterface dialog, int which){
                  }
              });
              //alertDialog.setIcon(R.drawable.icon);
              alertDialog.show();
              finish();
          }
      }); 
  }
  }
  </code></pre>
  
  <p>The issue is where it says AlertDialog alertDialog = new AlertDialog.Builder(this).create();</p>
  
  <p>It says the constructor is undefined. How do I fix that please?</p>