1

I really want to make an AlertDialog with single button, can someone guide me with this. Thanks!

4
  • 3
    any clues? language, platform, web/desktop Commented Mar 29, 2011 at 19:38
  • I want to creat an Alert Dialog in android Commented Mar 29, 2011 at 19:39
  • Which language and or platform are you working on? AlertDialog is possibly from Android, is that what you are working on? Commented Mar 29, 2011 at 19:40
  • the question is tagged with android, so yes. Commented Mar 29, 2011 at 19:42

2 Answers 2

3

Yes you can:

new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("Error")
.setMessage("Please fill out the entire form")
.setPositiveButton("Close", new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
})
.create()
.show()
;
Sign up to request clarification or add additional context in comments.

Comments

0

Use AlertDialog.Builder.

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    public onClick(DialogInterface dialog, int which) {
        // do something interesting.
    }
});
// other code to customize the dialog
Dialog d = builder.create();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.