List of usage examples for android.app AlertDialog getButton
public Button getButton(int whichButton)
From source file:de.persoapp.android.activity.dialog.NoInternetConnectionDialog.java
@SuppressWarnings("ConstantConditions") @Override/*from www . j a va 2s . co m*/ public void onResume() { super.onResume(); if (mNetworkHelper.isNetworkAvailable()) { closeDialog(); } else { AlertDialog dialog = (AlertDialog) getDialog(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); } }); getActivity().registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); mRegistered = true; } }
From source file:com.cachirulop.moneybox.common.ConfirmDialog.java
@Override public void onStart() { super.onStart(); AlertDialog dialog; dialog = (AlertDialog) getDialog();//w w w .j a v a 2 s . co m if (dialog != null) { Button positive; positive = (Button) dialog.getButton(Dialog.BUTTON_POSITIVE); positive.setOnClickListener(this); } }
From source file:de.eidottermihi.rpicheck.fragment.PassphraseDialog.java
@Override public void onStart() { super.onStart(); // super.onStart() is where dialog.show() is actually // called on the underlying dialog, so we have to do // it after this point AlertDialog d = (AlertDialog) getDialog(); if (d != null) { Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w. j a va 2s . c o m*/ public void onClick(View v) { // validate passphrase not empty if (!Strings.isNullOrEmpty(editTextPassphrase.getText().toString())) { final String passphrase = editTextPassphrase.getText().toString().trim(); final boolean savePassphrase = checkSavePassphrase.isChecked(); dismiss(); mPassphraseDialogListener.onPassphraseOKClick(PassphraseDialog.this, passphrase, savePassphrase, type); } else { editTextPassphrase.setError(getString(R.string.validation_msg_key_passphrase)); } } }); } }
From source file:com.cc.signalinfo.dialogs.ChangelogDialog.java
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean checkState) { AlertDialog ad = ((AlertDialog) this.getDialog()); // workaround for https://code.google.com/p/android/issues/detail?id=6360 if (ad != null) { ad.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(checkState); }//from w w w.j a va2 s.c o m SharedPreferences settings = getActivity().getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(AppSetup.PROMPT_SETTING, checkState).commit(); }
From source file:de.eidottermihi.rpicheck.fragment.CommandPlaceholdersDialog.java
@Override public void onStart() { super.onStart(); // super.onStart() is where dialog.show() is actually // called on the underlying dialog, so we have to do // it after this point AlertDialog d = (AlertDialog) getDialog(); if (d != null) { Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww.j a va2 s. co m public void onClick(View v) { // do replacements String cmd = command.getCommand(); for (Entry<String, EditText> entry : placeholderInputs.entrySet()) { String placeholder = entry.getKey(); String replacement = entry.getValue().getText().toString(); if (!Strings.isNullOrEmpty(replacement)) { cmd = cmd.replace(placeholder, replacement); } } command.setCommand(cmd); dismiss(); activityListener.onPlaceholdersOKClick(command, keyPass); } }); } }
From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Dialog_WatchData.java
@Override public void onStart() { super.onStart(); //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point AlertDialog d = (AlertDialog) getDialog(); if (d != null) { Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w. j a v a2 s .c o m*/ public void onClick(View arg0) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { clearLayoutList(); dismiss(); } }); } }); } }
From source file:org.akvo.caddisfly.sensor.ec.EditSensorIdentity.java
@Override public void onStart() { super.onStart(); final Context context = getActivity(); final AlertDialog d = (AlertDialog) getDialog(); if (d != null) { Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w. ja v a 2s . c om*/ public void onClick(View v) { if (formEntryValid() && !editId.getText().toString().trim().isEmpty()) { if (mListener != null) { mListener.onFragmentInteraction(editId.getText().toString()); } closeKeyboard(context, editId); dismiss(); } } private boolean formEntryValid() { if (editId.getText().toString().trim().isEmpty()) { editId.setError(getString(R.string.required)); return false; } return true; } }); } }
From source file:de.vanita5.twittnuker.fragment.support.DataExportImportTypeSelectorDialogFragment.java
private void updatePositiveButton(final DialogInterface dialog) { if (!(dialog instanceof AlertDialog)) return;//from ww w.j a v a 2 s . c o m final AlertDialog alertDialog = (AlertDialog) dialog; final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setEnabled(getCheckedFlags() != 0); }
From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuthAll.java
@Override public void onResume() { super.onResume(); AlertDialog d = (AlertDialog) getDialog(); if (d != null) { final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); final CheckBox cbYesAlready = (CheckBox) d.findViewById(R.id.rcm_cb_all); positiveButton.setEnabled(cbYesAlready.isChecked()); OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() { @Override/* w w w . ja v a 2s. c om*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { positiveButton.setEnabled(cbYesAlready.isChecked()); } }; cbYesAlready.setOnCheckedChangeListener(l); } }
From source file:com.drisoftie.frags.comp.BaseDiagResult.java
@Override public void onStart() { super.onStart(); AlertDialog diag = (AlertDialog) getDialog(); if (getArguments().containsKey(getString(R.string.bundl_diag_btn_positive))) { diag.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override// ww w . j a v a2 s . c om public void onClick(View v) { setResultState(DialogResultState.POSITIVE); buttonPositivePressed(); } }); } if (getArguments().containsKey(getString(R.string.bundl_diag_btn_positive))) { diag.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setResultState(DialogResultState.NEGATIVE); buttonNegativePressed(); } }); } }