Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DOC

How to create alert in android

Some times it is a need to popup a message as warning message or alert message for the user and also give option to the user to close that popup after reading the message.
So following the below set of code you can do it easily.

1. Initialising.

AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Test Title").setPositiveButton("ok", new OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();                        
    }
});

2. Execution

alert.setMessage("Your Warning Message").show();
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home