Mgamerz

Untitled

Jul 1st, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. public class ExampleApp extends Activity {
  2.     @Override
  3.     protected void onCreate(Bundle savedInstanceState) {
  4.         super.onCreate(savedInstanceState);
  5.         setContentView(R.layout.main);
  6.         AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
  7.         alt_bld.setMessage("Do you want to close this window ?")
  8.                 .setCancelable(false)
  9.                 .setPositiveButton("Yes",
  10.                         new DialogInterface.OnClickListener() {
  11.                             public void onClick(DialogInterface dialog, int id) {
  12.                                 // Action for 'Yes' Button
  13.                             }
  14.                         })
  15.                 .setNegativeButton("No", new DialogInterface.OnClickListener() {
  16.                     public void onClick(DialogInterface dialog, int id) {
  17.                         // Action for 'NO' Button
  18.                         dialog.cancel();
  19.                     }
  20.                 });
  21.         AlertDialog alert = alt_bld.create();
  22.         // Title for AlertDialog
  23.         alert.setTitle("Title");
  24.         // Icon for AlertDialog
  25.         alert.setIcon(R.drawable.icon);
  26.         alert.show();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment