Android basic alertdialog

Source: Internet
Author: User

In Android, creating a dialog box is relatively simple. New alertdialog. Builder is used to set its information, such as the displayed content, title, whether the dialog box can be canceled by the Return key, OK, and cancel buttons.

,

 

     new AlertDialog.Builder(EX03_12.this) 
.setTitle(R.string.app_about)
.setMessage(R.string.app_about_msg)
.setCancelable(false)
.setPositiveButton(R.string.str_ok,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialoginterface, int i)
{
}
})
.setNegativeButton(R.string.str_cancel,
new DialogInterface.OnClickListener()
{

@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
finish();
}
}).show();

Setcancelable (false) indicates that you cannot use the return key on your phone to cancel the dialog box. setpositivebutton () and. setnegativebutton () respectively set the events of the confirm button and the events of the cancel button.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.