Reputation: 533
I really want to make an AlertDialog with single button, can someone guide me with this. Thanks!
Upvotes: 1
Views: 2756
Reputation: 73484
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();
Upvotes: 0
Reputation: 26271
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()
;
Upvotes: 3