title: Android dialog.getButton(AlertDialog.BUTTON_POSITIVE) Null Pointer
body: <p>I cannot get <code>dialog.getButton(AlertDialog.BUTTON_POSITIVE)</code> to work. I always get a null pointer exception, even though I use the <code>.setPositiveButton()</code> method. I saw that this was an issue in <a href="https://code.google.com/p/android/issues/detail?id=6360" rel="nofollow">FroYo</a>, but I am on V 4.4. I haven't seen any logged problems with this so I have no clue what the issue is </p>
  
  <p>Code:</p>
  
  <pre><code>AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this)
          .setTitle(R.string.delete_db_on_exit)
          .setCustomTitle(dialogView)
          .setPositiveButton(R.string.confirm_button_text, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                  if (((CheckBox) dialogView.findViewById(R.id.confirm_delete_checkbox)).isChecked()) {
                      _application.setDeleteDatabaseOnExit();
                      dialog.cancel();
                      //Navigate back to main activity
                      Intent mainActivityIntent = new Intent(AdministrationActivity.this, MainActivity.class);
                      startActivityForResult(mainActivityIntent, 1);
                  } else {
                      Toast.makeText(context, "Please click the confirmation checkbox before continuing", Toast.LENGTH_LONG).show();
                  }
              }
          });
  dialog = dialogBuilder.create();
  Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
  positiveButton.setEnabled(false);
  </code></pre>