本文整理汇总了Java中android.content.DialogInterface.OnCancelListener方法的典型用法代码示例。如果您正苦于以下问题:Java DialogInterface.OnCancelListener方法的具体用法?Java DialogInterface.OnCancelListener怎么用?Java DialogInterface.OnCancelListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.DialogInterface
的用法示例。
在下文中一共展示了DialogInterface.OnCancelListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLoadingDialog
import android.content.DialogInterface; //导入方法依赖的package包/类
/**
* 有取消回调的进度dialog
* @param context
* @param msg
* @return
*/
public static Dialog createLoadingDialog(Activity context, String msg, DialogInterface.OnCancelListener listener) {
final Dialog dialog = new Dialog(context , R.style.NoBackGroundDialog);
dialog.show();
dialog.setCanceledOnTouchOutside(false);
if(listener != null) dialog.setOnCancelListener(listener);
Window window = dialog.getWindow();
assert window != null;
window.setGravity(Gravity.CENTER);
int width = ScreenUtil.getWidth(context) * 2 / 3;
window.setLayout(width,
android.view.WindowManager.LayoutParams.WRAP_CONTENT);
View view = context.getLayoutInflater().inflate(
R.layout.loading_dialog, null);
TextView tipTextView = (TextView) view.findViewById(R.id.tipTextView);// 提示文字
if(!TextUtils.isEmpty(msg)){
tipTextView.setText(msg);// 设置加载信息
}
window.setContentView(view);//
return dialog;
}
示例2: createJDLoadingDialog
import android.content.DialogInterface; //导入方法依赖的package包/类
/**
* gif动画进度
* @param context
*
* @return
*/
public static Dialog createJDLoadingDialog(Activity context, DialogInterface.OnCancelListener listener) {
final Dialog dialog = new Dialog(context , R.style.NoBackGroundDialog);
dialog.show();
dialog.setCanceledOnTouchOutside(false);
if(listener != null) dialog.setOnCancelListener(listener);
Window window = dialog.getWindow();
assert window != null;
window.setGravity(Gravity.CENTER);
window.setLayout(android.view.WindowManager.LayoutParams.WRAP_CONTENT,
android.view.WindowManager.LayoutParams.WRAP_CONTENT);
View view = context.getLayoutInflater().inflate(
R.layout.jd_loading_dialog, null);
window.setContentView(view);//
return dialog;
}
示例3: show
import android.content.DialogInterface; //导入方法依赖的package包/类
public void show(Context context, @StringRes int titleId, @StringRes int messageId,
DialogInterface.OnCancelListener listener) {
dismiss();
DialogBuilder builder = new DialogBuilder(context);
if (titleId > 0) {
builder.setTitle(titleId);
}
LayoutInflater inflater = LayoutInflater.from(context);
View itemView = inflater.inflate(R.layout.row_progress, null);
messageTextView = (TextView) itemView.findViewById(R.id.text_progress);
if (messageId > 0) {
messageTextView.setText(messageId);
}
builder.addItem(itemView);
builder.setOnCancelListener(listener);
dialog = builder.show();
}
示例4: showAlert
import android.content.DialogInterface; //导入方法依赖的package包/类
public static AlertDialog showAlert(final Context context, final String title, final View view, final DialogInterface.OnCancelListener lCancel) {
if (context instanceof Activity && ((Activity) context).isFinishing()) {
return null;
}
final Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setView(view);
// builder.setCancelable(true);
builder.setOnCancelListener(lCancel);
final AlertDialog alert = builder.create();
alert.show();
return alert;
}
示例5: showProgressDialog
import android.content.DialogInterface; //导入方法依赖的package包/类
protected void showProgressDialog(String msg , DialogInterface.OnCancelListener listener){
if(loadingDialog == null){
loadingDialog = DialogUtil.createLoadingDialog(this, msg, listener);
}else if(!loadingDialog.isShowing()){
loadingDialog.show();
}
}
示例6: executeCropTaskAfterPrompt
import android.content.DialogInterface; //导入方法依赖的package包/类
/**
* Calls cropTask.execute(), once the user has selected which wallpaper to set. On pre-N
* devices, the prompt is not displayed since there is no API to set the lockscreen wallpaper.
* <p>
* TODO: Don't use CropAndSetWallpaperTask on N+, because the new API will handle cropping instead.
*/
public static void executeCropTaskAfterPrompt(
Context context, final AsyncTask<Integer, ?, ?> cropTask,
DialogInterface.OnCancelListener onCancelListener) {
if (Utilities.isNycOrAbove()) {
new AlertDialog.Builder(context)
.setTitle(R.string.wallpaper_instructions)
.setItems(R.array.which_wallpaper_options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int selectedItemIndex) {
int whichWallpaper;
if (selectedItemIndex == 0) {
whichWallpaper = WallpaperManagerCompat.FLAG_SET_SYSTEM;
} else if (selectedItemIndex == 1) {
whichWallpaper = WallpaperManagerCompat.FLAG_SET_LOCK;
} else {
whichWallpaper = WallpaperManagerCompat.FLAG_SET_SYSTEM
| WallpaperManagerCompat.FLAG_SET_LOCK;
}
cropTask.execute(whichWallpaper);
}
})
.setOnCancelListener(onCancelListener)
.show();
} else {
cropTask.execute(WallpaperManagerCompat.FLAG_SET_SYSTEM);
}
}
示例7: CommonDialog
import android.content.DialogInterface; //导入方法依赖的package包/类
protected CommonDialog(Context context, boolean flag,
DialogInterface.OnCancelListener listener) {
super(context, flag, listener);
contentPadding = (int) getContext().getResources().getDimension(
R.dimen.global_dialog_padding);
init(context);
}
示例8: showProgressDialog
import android.content.DialogInterface; //导入方法依赖的package包/类
private void showProgressDialog(
@Nullable final String message,
final boolean cancelable,
@Nullable final DialogInterface.OnCancelListener cancelListener) {
final ProgressDialog prevDialog = dialogAtomicReference.getAndSet(null);
if (prevDialog != null && prevDialog.isShowing()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
prevDialog.dismiss();
}
});
}
runOnUiThread(new Runnable() {
@Override
public void run() {
final ProgressDialog newDialog = ProgressDialog.show(
// Context
MainActivity.this,
// Title
null,
// Message
message,
// Indeterminate
true,
// Cancelable
cancelable,
// CancelListener
cancelListener
);
if (!dialogAtomicReference.compareAndSet(null, newDialog)) {
newDialog.dismiss();
}
}
});
}
示例9: setOnCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
public Builder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
builder.setOnCancelListener(onCancelListener);
return this;
}
示例10: setOnCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
public void setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
mOnCancelListener = onCancelListener;
}
示例11: setOnCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public void setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
mOnCancelListener = onCancelListener;
}
示例12: setOnCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
public DialogBuilder setOnCancelListener(DialogInterface.OnCancelListener listener) {
getDialog().setOnCancelListener(listener);
return this;
}
示例13: setOnCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
public void setOnCancelListener(DialogInterface.OnCancelListener listener){
dialog.setOnCancelListener(listener);
}
示例14: getOnDialogCancelListener
import android.content.DialogInterface; //导入方法依赖的package包/类
public DialogInterface.OnCancelListener getOnDialogCancelListener() {
return mOnDialogCancelListener;
}
示例15: showError
import android.content.DialogInterface; //导入方法依赖的package包/类
/**
* 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 = newAlertDlg(context);
dlg.setIcon(android.R.drawable.ic_dialog_alert);
dlg.setTitle(R.string.afc_title_error);
dlg.setMessage(msg);
dlg.setOnCancelListener(listener);
dlg.show();
}