• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps The constructor AlertDialog.Builder is undefined

cr5315

Android Enthusiast
Jul 23, 2010
434
158
Narnia
cr5315.com
I am trying to make an alert dialog, but after I entered all the code, Eclipse gave me an error on a line that reads
Code:
AlertDialog.Builder builder = [COLOR="Red"]new AlertDialog.Builder(this)[/COLOR];
More specifically new AlertDialog.Builder(this)
The error says, "The constructor AlertDialog.Builder(new View.OnClickListener(){}) is undefined.
I can't find any solutions on developer.android.com, but I might just be bad at looking. I used the Google example and the same thing happened.
Here is the the rest of the code.
Code:
Button aboutButton = (Button) findViewById(R.id.Button06);
	aboutButton.setOnClickListener(new View.OnClickListener(){
		public void onClick(View v) {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("The Crossing Version 0.1")
			       .setCancelable(true)
			       .setNeutralButton("Close", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			                crossingActivity.this.finish();
			           }
			       
			           
			       });
			AlertDialog alert = builder.create();
		}
 
Button aboutButton = (Button) findViewById(R.id.Button06);
aboutButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
new AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The Crossing Version 0.1")
.setCancelable(true)
.setNeutralButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
crossingActivity.this.finish();
}


});
AlertDialog alert = builder.create();
}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones