document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public void openDialog() {
  2.  
  3.         AlertDialog alertDialog = new AlertDialog.Builder(this).create();
  4.  
  5.         TextView title = new TextView(this);
  6.         // Title Properties
  7.         title.setText("Custom Dialog Box");
  8.         title.setPadding(10, 10, 10, 10);   // Set Position
  9.         title.setGravity(Gravity.CENTER);
  10.         title.setTextColor(Color.BLACK);
  11.         title.setTextSize(20);
  12.         alertDialog.setCustomTitle(title);
  13.  
  14.         TextView msg = new TextView(this);
  15.         msg.setText("I am a Custom Dialog Box. \\n Please Customize me.");
  16.         msg.setGravity(Gravity.CENTER_HORIZONTAL);
  17.         msg.setTextColor(Color.BLACK);
  18.         alertDialog.setView(msg);
  19.  
  20.         alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL,"OK", new DialogInterface.OnClickListener() {
  21.             public void onClick(DialogInterface dialog, int which) {
  22.                 // SetAction untuk melakukan sesuatu
  23.             }
  24.         });
  25.  
  26.         alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE,"CANCEL", new DialogInterface.OnClickListener() {
  27.             public void onClick(DialogInterface dialog, int which) {
  28.                
  29.                 // SetAction untuk melakukan sesua
  30.             }
  31.         });
  32.  
  33.         new Dialog(getApplicationContext());
  34.         alertDialog.show();
  35.  
  36.         final Button okBT = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
  37.         LinearLayout.LayoutParams neutralBtnLP = (LinearLayout.LayoutParams) okBT.getLayoutParams();
  38.         neutralBtnLP.gravity = Gravity.FILL_HORIZONTAL;
  39.         okBT.setPadding(50, 10, 10, 10);  
  40.         okBT.setTextColor(Color.BLUE);
  41.         okBT.setLayoutParams(neutralBtnLP);
');