List of usage examples for android.app AlertDialog getButton
public Button getButton(int whichButton)
From source file:eu.geopaparazzi.core.ui.dialogs.GpxImportDialogFragment.java
public void onStart() { super.onStart(); AlertDialog d = (AlertDialog) getDialog(); if (d != null) { positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setEnabled(false); }/*w w w . ja va2s.c o m*/ startImport(); }
From source file:org.thbz.hanguldrill.ConfigManageDialogFragment.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 final AlertDialog d = (AlertDialog) getDialog(); if (d != null) { Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override//from ww w .jav a2 s . com public void onClick(View v) { // Only dismiss the dialog if the user confirms the deletion int nbToDelete = configsSelected.size(); if (nbToDelete == 0) { alert("You have selected no configuration."); } else { // Confirm String message = "Do you really want to delete " + nbToDelete + " configuration" + (nbToDelete >= 2 ? "s" : "") + "?"; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog dialog = builder.setMessage(message) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Save the configurations and dismiss the dialog mListener.onConfigManageSaveClick(configsSelected); d.dismiss(); } }).setNegativeButton("No", null).create(); dialog.show(); } } }); } }
From source file:com.reliqartz.firsttipcalc.gui.RatioDialog.java
@Override public void onStart() { super.onStart(); // prevent canceling setCancelable(false);/*from w ww. j a va2 s .c om*/ // setup TextWatcher for input mRatioEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // do nothing } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // do nothing } @Override public void afterTextChanged(Editable s) { String str = s.toString(); // allow only 0-9 and : if (str.length() > 0) { int length = str.length(); // if last character is not allowed if (!str.substring(length - 1, length).matches("[:0-9]")) { str = str.substring(0, length - 1); s.clear(); // clear editable s.append(str); // append acceptable string } } } }); // get the shown dialog and override the positive buttons OnClickListener AlertDialog dialog = (AlertDialog) getDialog(); if (dialog != null) { dialog.getButton(Dialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String ratio = mRatioEditText.getText().toString(); if (ValidTextUtils.validRatio(ratio, mSplitFor) || mAllowClose) { mActivity.onSplitRatioChanged(ratio); dismiss(); } else { Toast.makeText(getActivity(), getString(R.string.ratio_invalid, mSplitFor), Toast.LENGTH_SHORT).show(); } } }); } }
From source file:eu.geopaparazzi.core.ui.dialogs.GpxExportDialogFragment.java
public void onStart() { super.onStart(); AlertDialog d = (AlertDialog) getDialog(); if (d != null) { positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); positiveButton.setEnabled(false); }/* w w w . ja va 2s . c om*/ startExport(); }
From source file:org.projectbuendia.client.ui.dialogs.OrderDialogFragment.java
@Override public void onResume() { super.onResume(); // Replace the existing button listener so we can control whether the dialog is dismissed. final AlertDialog dialog = (AlertDialog) getDialog(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override/* w ww. ja v a2 s .com*/ public void onClick(View view) { onSubmit(dialog); } }); }
From source file:org.thialfihar.android.apg.ui.dialog.ShareQrCodeDialogFragment.java
@Override public void onResume() { super.onResume(); if (!mFingerprintOnly) { AlertDialog alertDialog = (AlertDialog) getDialog(); final Button backButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); final Button nextButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); backButton.setOnClickListener(new View.OnClickListener() { @Override//w w w . jav a 2s.c o m public void onClick(View v) { if (mCounter > 0) { mCounter--; updatePartsQrCode(); updateDialog(backButton, nextButton); } else { dismiss(); } } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mCounter < mContentList.size() - 1) { mCounter++; updatePartsQrCode(); updateDialog(backButton, nextButton); } else { dismiss(); } } }); } }
From source file:com.shalzz.attendance.fragment.CaptchaDialogFragment.java
/** * Called when the DialogView is started. Used to setup the onClick listeners. *//* ww w. java2 s . co m*/ @Override public void onStart() { super.onStart(); // Reference the views from the layout Dialog dialogView = CaptchaDialogFragment.this.getDialog(); Button bRefreshCaptcha = (Button) dialogView.findViewById(R.id.bRefresh); Captxt = (EditText) dialogView.findViewById(R.id.etCapTxt); ivCapImg = (ImageView) dialogView.findViewById(R.id.ivCapImg); pbar = (ProgressBar) dialogView.findViewById(R.id.progressBar1); AlertDialog alertDialog = (AlertDialog) getDialog(); final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); // Get the Captcha Image getImg(); // OnClickListener event for the Reload captcha Button bRefreshCaptcha.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i(LoginActivity.class.toString(), "Refreshing Captcha..."); getImg(); Captxt.setText(""); } }); // logs in when user press done on keyboard. Captxt.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { positiveButton.performClick(); return true; } return false; } }); }
From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuth.java
@Override public void onResume() { super.onResume(); AlertDialog d = (AlertDialog) getDialog(); if (d != null) { final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE); final RadioButton rbPre = (RadioButton) d.findViewById(R.id.rcm_rb_pre); final RadioButton rbAll = (RadioButton) d.findViewById(R.id.rcm_rb_all); all = rbAll.isChecked();/* ww w .j a v a 2 s. c o m*/ positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked()); OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked()); all = rbAll.isChecked(); } }; rbPre.setOnCheckedChangeListener(l); rbAll.setOnCheckedChangeListener(l); } }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
/** * Show a warning that has a specific count down to auto-cancel. * @param context Context./*from w w w. j a v a 2 s . c o m*/ * @param msg Message String ID. * @param countSecs Length in seconds to show message before auto-cancelling. * @param onOK Callback for when "OK" is selected. * @return */ public static AlertDialog showWarning(final Context context, int msg, int countSecs, DialogInterface.OnClickListener onOK) { final Timer timer = new Timer("Count Down"); final AlertDialog dlg = new AlertDialog.Builder(context).setMessage(msg) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); timer.cancel(); } }).setCancelable(true).setPositiveButton(android.R.string.ok, onOK).show(); final int[] cnt = new int[] { countSecs }; final Button btCancel = dlg.getButton(DialogInterface.BUTTON_NEGATIVE); TimerTask tt = new TimerTask() { @Override public void run() { if (dlg.isShowing()) { btCancel.post(new Runnable() { public void run() { btCancel.setText(context.getResources().getString(android.R.string.cancel) + " (" + cnt[0]-- + ")"); } }); } else cnt[0] = 0; if (cnt[0] <= 0) cancel(); } @Override public boolean cancel() { dlg.cancel(); return super.cancel(); } }; timer.scheduleAtFixedRate(tt, 0, 1000); return dlg; }
From source file:com.dsi.ant.antplus.pluginsampler.geocache.Dialog_GeoRequestAuthToken.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 w w w . j av a 2 s . com*/ public void onClick(View v) { final Dialog_ProgressWaiter progressDialog = new Dialog_ProgressWaiter("Requesting Auth Token"); int nonce; long serialNum; try { nonce = Integer.parseInt(editText_Nonce.getText().toString()); serialNum = Long.parseLong(editText_SerialNumber.getText().toString()); } catch (NumberFormatException e) { Toast.makeText(getActivity(), "Could not parse number", Toast.LENGTH_SHORT).show(); return; } //Use the current deviceID and PIN boolean reqSubmitted = geoPcc.requestAuthToken(deviceID, nonce, serialNum, new IAuthTokenRequestFinishedReceiver() { @Override public void onNewAuthTokenRequestFinished(GeocacheRequestStatus status, final long authToken) { StringBuilder resultDesc = new StringBuilder("Error Requesting Token: "); switch (status) { case SUCCESS: getActivity().runOnUiThread(new Runnable() { @Override public void run() { progressDialog.dismiss(); textView_Status.setText("Authentication token received: 0x" + Long.toHexString(authToken)); } }); return; case FAIL_DEVICE_NOT_IN_LIST: resultDesc.append("Device no longer in list"); break; case FAIL_ALREADY_BUSY_EXTERNAL: resultDesc.append("Device is busy"); break; case FAIL_DEVICE_COMMUNICATION_FAILURE: resultDesc.append("Communication with device failed"); break; case FAIL_BAD_PARAMS: resultDesc.append("Bad Parameters"); break; case UNRECOGNIZED: //TODO This flag indicates that an unrecognized value was sent by the service, an upgrade of your PCC may be required to handle this new value. resultDesc.append("Unrecognized failure"); break; } final String resultStr = resultDesc.toString(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { progressDialog.dismiss(); Toast.makeText(getActivity(), resultStr, Toast.LENGTH_LONG).show(); } }); } }, progressDialog.getUpdateReceiver()); if (reqSubmitted) progressDialog.show(getActivity().getSupportFragmentManager(), "RequestAuthTokenDialog"); else Toast.makeText(getActivity(), "Error Requesting Token: PCC already busy or dead", Toast.LENGTH_SHORT).show(); //now both dialogs stay open. They get closed in the programming result handler. } }); } }