android.app.AlertDialog.setOnCancelListener()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中android.app.AlertDialog.setOnCancelListener()方法的一些代码示例,展示了AlertDialog.setOnCancelListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlertDialog.setOnCancelListener()方法的具体详情如下:
包路径:android.app.AlertDialog
类名称:AlertDialog
方法名:setOnCancelListener

AlertDialog.setOnCancelListener介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

alertDialog = buildAlertDialog(context);
alertDialog.setOnDismissListener(this);
alertDialog.setOnCancelListener(this);
show();

代码示例来源:origin: stackoverflow.com

public void showAlertDialog(final Activity activity, String title, String message, Boolean status) {

 AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
      public void onCancel(DialogInterface dialog) {
        activity.finish();
      }
    });

 alertDialog.show();
}

代码示例来源:origin: zhaoyang21cn/iLiveSDK_Android_Suixinbo

private void processOffline(String message){
  if (isDestroyed() || isFinishing()) {
    return;
  }
  AlertDialog alertDialog = new AlertDialog.Builder(this)
      .setTitle(R.string.str_tips_title)
      .setMessage(message)
      .setPositiveButton(R.string.btn_sure, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
          dialogInterface.cancel();
        }
      })
      .create();
  alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialogInterface) {
      requiredLogin();
    }
  });
  alertDialog.show();
}

代码示例来源:origin: zhaoyang21cn/iLiveSDK_Android_Suixinbo

private void processOffline(String message){
  if (isDestroyed() || isFinishing()) {
    return;
  }
  AlertDialog alertDialog = new AlertDialog.Builder(this)
      .setTitle(R.string.str_tips_title)
      .setMessage(message)
      .setPositiveButton(R.string.btn_sure, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
          dialogInterface.cancel();
        }
      })
      .create();
  alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialogInterface) {
      requiredLogin();
    }
  });
  alertDialog.show();
}

代码示例来源:origin: stackoverflow.com

public static void getConfirmDialog(Context mContext,String title, String msg, String positiveBtnCaption, String negativeBtnCaption, boolean isCancelable, final AlertMagnatic target) {
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   int imageResource = android.R.drawable.ic_dialog_alert;
   Drawable image = mContext.getResources().getDrawable(imageResource);
   builder.setTitle(title).setMessage(msg).setIcon(image).setCancelable(false).setPositiveButton(positiveBtnCaption, new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int id) {
       target.PositiveMethod(dialog, id);
     }
   }).setNegativeButton(negativeBtnCaption, new DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int id) {
       target.NegativeMethod(dialog, id);
     }
   });
   AlertDialog alert = builder.create();
   alert.setCancelable(isCancelable);
   alert.show();
   if (isCancelable) {
     alert.setOnCancelListener(new OnCancelListener() {
       @Override
       public void onCancel(DialogInterface arg0) {
         target.NegativeMethod(null, 0);
       }
     });
   }
 }

代码示例来源:origin: stackoverflow.com

public static void getConfirmDialog(Context mContext,String title, String msg, String positiveBtnCaption, String negativeBtnCaption, boolean isCancelable, final AlertMagnatic target) {
   AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   int imageResource = android.R.drawable.ic_dialog_alert;
   Drawable image = mContext.getResources().getDrawable(imageResource);
   builder.setTitle(title).setMessage(msg).setIcon(image).setCancelable(false).setPositiveButton(positiveBtnCaption, new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int id) {
       target.PositiveMethod(dialog, id);
     }
   }).setNegativeButton(negativeBtnCaption, new DialogInterface.OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int id) {
       target.NegativeMethod(dialog, id);
     }
   });
   AlertDialog alert = builder.create();
   alert.setCancelable(isCancelable);
   alert.show();
   if (isCancelable) {
     alert.setOnCancelListener(new OnCancelListener() {
       @Override
       public void onCancel(DialogInterface arg0) {
         target.NegativeMethod(null, 0);
       }
     });
   }
 }

代码示例来源:origin: limboemu/limbo

alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
  @Override
  public void onCancel(DialogInterface dialog) {

代码示例来源:origin: zhaoyang21cn/iLiveSDK_Android_Suixinbo

@Override
public void forceQuitRoom(String strMessage) {
  if (isDestroyed() || isFinishing()) {
    return;
  }
  ILiveRoomManager.getInstance().onPause();
  AlertDialog alertDialog = new AlertDialog.Builder(this)
      .setTitle(R.string.str_tips_title)
      .setMessage(strMessage)
      .setPositiveButton(R.string.btn_sure, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
          dialogInterface.cancel();
        }
      })
      .create();
  alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialogInterface) {
      callExitRoom();
    }
  });
  alertDialog.show();
}

代码示例来源:origin: limboemu/limbo

private void promptPrio(final Activity activity) {
  final AlertDialog alertDialog;
  alertDialog = new AlertDialog.Builder(activity).create();
  alertDialog.setTitle("Enable High Priority!");
  TextView textView = new TextView(activity);
  textView.setVisibility(View.VISIBLE);
  textView.setPadding(20, 20, 20, 20);
  textView.setText("Warning! High Priority might increase emulation speed but " + "will slow your phone down!");
  alertDialog.setView(textView);
  alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      LimboSettingsManager.setPrio(activity, true);
    }
  });
  alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      mPrio.setChecked(false);
      return;
    }
  });
  alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialog) {
      mPrio.setChecked(false);
    }
  });
  alertDialog.show();
}

代码示例来源:origin: stackoverflow.com

alert.show();
if (isCancelable) {
  alert.setOnCancelListener(new OnCancelListener() {

代码示例来源:origin: stackoverflow.com

AsyncTask<Void,Void,Void> task = new AsyncTask<Void, Void, Void>() {
   private AlertDialog dialog;
   @Override
   protected void onPreExecute() {
     super.onPreExecute();
     dialog= new AlertDialog.Builder(MainActivity.this);
     dialog.setTitle("Detecting.....");
     dialog.setMessage("Please Wait");
     dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
       @Override
       public void onCancel(DialogInterface dialogInterface) {
         cancel(true);
       }
     });
     dialog.show();
   }
   @Override
   protected Void doInBackground(Void... voids) {
     timeConsumingDetectMethod();
     return null;
   }
   @Override
   protected void onPostExecute(Void aVoid) {
     super.onPostExecute(aVoid);
     dialog.dismiss();
   }
 }.execute();

代码示例来源:origin: limboemu/limbo

alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
  @Override
  public void onCancel(DialogInterface dialog) {

代码示例来源:origin: adolfAn/FBReader_AS

/**
 * Shows an error message.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param listener
 *            will be called after the user cancelled the dialog.
 */
public static void showError(Context context, CharSequence msg, DialogInterface.OnCancelListener listener) {
  AlertDialog dlg = newDlg(context);
  dlg.setIcon(android.R.drawable.ic_dialog_alert);
  dlg.setTitle(R.string.afc_title_error);
  dlg.setMessage(msg);
  dlg.setOnCancelListener(listener);
  dlg.show();
}// showError()

代码示例来源:origin: limboemu/limbo

alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
  @Override
  public void onCancel(DialogInterface dialog) {

代码示例来源:origin: adolfAn/FBReader_AS

/**
 * Shows a confirmation dialog.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param onYes
 *            will be called if the user selects positive answer (a
 *            <i>Yes</i> or <i>OK</i>).
 * @param onNo
 *            will be called after the user cancelled the dialog.
 */
public static void confirmYesno(Context context, CharSequence msg, DialogInterface.OnClickListener onYes,
    DialogInterface.OnCancelListener onNo) {
  AlertDialog dlg = newDlg(context);
  dlg.setIcon(android.R.drawable.ic_dialog_alert);
  dlg.setTitle(R.string.afc_title_confirmation);
  dlg.setMessage(msg);
  dlg.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.yes), onYes);
  dlg.setOnCancelListener(onNo);
  dlg.show();
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
  protected void onProgressUpdate(final String... values) {
    final int length = LengthUtils.length(values);
    if (length == 0) {
      return;
    }
    final String last = values[length - 1];
    if (progressDialog == null || !progressDialog.isShowing()) {
      progressDialog = new AlertDialog.Builder(context).setMessage(last).show();
      if (cancellable) {
        progressDialog.setCancelable(true);
        progressDialog.setCanceledOnTouchOutside(true);
        progressDialog.setOnCancelListener(this);
      } else {
        progressDialog.setCancelable(false);
        progressDialog.setCanceledOnTouchOutside(false);
      }
    } else {
      progressDialog.setMessage(last);
    }
  }
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
  protected void onProgressUpdate(final String... values) {
    final int length = LengthUtils.length(values);
    if (length == 0) {
      return;
    }
    final String last = values[length - 1];
    try {
      if (progressDialog == null || !progressDialog.isShowing()) {
        progressDialog = ProgressDialog.show(context, "", last, true);
        progressDialog.setCancelable(true);
        progressDialog.setCanceledOnTouchOutside(true);
        progressDialog.setOnCancelListener(this);
      } else {
        progressDialog.setMessage(last);
      }
    } catch (final Throwable th) {
    }
  }
}

代码示例来源:origin: quaap/LaunchTime

Dialog createDialog() {
  mAdapter = new ArrayAdapter<>(CustomizeLaunchersActivity.this, R.layout.add_list_item);
  mAdapter.add(getString(R.string.custom_icon_select_picture));
  mAdapter.add(getString(R.string.custom_icon_icon_packs));
  if (SpecialIconStore.hasBitmap(CustomizeLaunchersActivity.this, mAppClicked.getComponentName(), SpecialIconStore.IconType.Custom)) {
    mAdapter.add(getString(R.string.custom_icon_clear_icon));
  }
  final AlertDialog.Builder builder = new AlertDialog.Builder(CustomizeLaunchersActivity.this);
  builder.setTitle(R.string.custom_icon_select_icon_type);
  builder.setAdapter(mAdapter, this);
  //builder.setInverseBackgroundForced(false);
  AlertDialog dialog = builder.create();
  dialog.setOnCancelListener(this);
  dialog.setOnDismissListener(this);
  dialog.setOnShowListener(this);
  return dialog;
}
public void onCancel(DialogInterface dialog) {

代码示例来源:origin: stackoverflow.com

@Override
 public void onBackPressed() {
 final AlertDialog alert = new AlertDialog.Builder(new ContextThemeWrapper(contextForAlert,R.style.CustomAlertDialogue)).create();
 alert.setTitle(title);
 alert.setMessage(message);
 alert.setIcon(R.drawable.warning_icon);
 alert.setCancelable(false);
 alert.setCanceledOnTouchOutside(false);
 alert.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 }
 });
 alert.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int which) {
     alert.dismiss();    
    }
   });
 alert.setOnCancelListener(new DialogInterface.OnCancelListener() {
     @Override
     public void onCancel(DialogInterface dialog) {
     }
   });
 alert.show();
 }

代码示例来源:origin: geekyouup/ultimatestopwatch

mSelectTime.setOnCancelListener(new DialogInterface.OnCancelListener() {
  @Override
  public void onCancel(DialogInterface dialogInterface) {

相关文章