本文整理了Java中android.app.Dialog.setCancelable()
方法的一些代码示例,展示了Dialog.setCancelable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dialog.setCancelable()
方法的具体详情如下:
包路径:android.app.Dialog
类名称:Dialog
方法名:setCancelable
暂无
代码示例来源:origin: Bigkoo/Android-PickerView
/**
* 设置对话框模式是否可以点击外部取消
*/
public void setDialogOutSideCancelable() {
if (mDialog != null) {
mDialog.setCancelable(mPickerOptions.cancelable);
}
}
代码示例来源:origin: rey5137/material
public BottomSheetDialog cancelable(boolean cancelable){
super.setCancelable(cancelable);
mCancelable = cancelable;
return this;
}
代码示例来源:origin: rey5137/material
/**
* Sets whether this dialog is cancelable with the
* {@link android.view.KeyEvent#KEYCODE_BACK BACK} key.
* @return The Dialog for chaining methods.
*/
public Dialog cancelable(boolean cancelable){
super.setCancelable(cancelable);
mCancelable = cancelable;
return this;
}
代码示例来源:origin: gzu-liyujiang/AndroidPicker
public void setCancelable(boolean flag) {
dialog.setCancelable(flag);
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
public static Dialog showDialogForLoading(Activity context) {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
TextView loadingText = (TextView)view.findViewById(R.id.id_tv_loading_dialog_text);
loadingText.setText("加载中...");
mLoadingDialog = new Dialog(context, R.style.CustomProgressDialog);
mLoadingDialog.setCancelable(true);
mLoadingDialog.setCanceledOnTouchOutside(false);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
mLoadingDialog.show();
return mLoadingDialog;
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 显示加载对话框
* @param context 上下文
* @param msg 对话框显示内容
* @param cancelable 对话框是否可以取消
*/
public static Dialog showDialogForLoading(Activity context, String msg, boolean cancelable) {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
TextView loadingText = (TextView)view.findViewById(R.id.id_tv_loading_dialog_text);
loadingText.setText(msg);
mLoadingDialog = new Dialog(context, R.style.CustomProgressDialog);
mLoadingDialog.setCancelable(cancelable);
mLoadingDialog.setCanceledOnTouchOutside(false);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
mLoadingDialog.show();
return mLoadingDialog;
}
代码示例来源:origin: Bigkoo/Android-PickerView
public void createDialog() {
if (dialogView != null) {
mDialog = new Dialog(context, R.style.custom_dialog2);
mDialog.setCancelable(mPickerOptions.cancelable);//不能点外面取消,也不能点back取消
mDialog.setContentView(dialogView);
Window dialogWindow = mDialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setWindowAnimations(R.style.picker_view_scale_anim);
dialogWindow.setGravity(Gravity.CENTER);//可以改成Bottom
}
mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (onDismissListener != null) {
onDismissListener.onDismiss(BasePickerView.this);
}
}
});
}
}
代码示例来源:origin: igreenwood/SimpleCropView
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// タッチしても消えないように設定
dialog.setCancelable(false);
// ビュー全体のリスナ
dialog.setCanceledOnTouchOutside(false);
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// Disable Back key and Search key
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_SEARCH:
return true;
default:
return false;
}
}
});
return dialog;
}
}
代码示例来源:origin: aa112901/remusic
splashDialog.setCancelable(false);
splashDialog.show();
代码示例来源:origin: aa112901/remusic
splashDialog.setCancelable(false);
splashDialog.show();
代码示例来源:origin: aa112901/remusic
splashDialog.setCancelable(false);
splashDialog.show();
代码示例来源:origin: gzu-liyujiang/AndroidPicker
private void initDialog() {
contentLayout = new FrameLayout(activity);
contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
contentLayout.setFocusable(true);
contentLayout.setFocusableInTouchMode(true);
dialog = new Dialog(activity);
dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
dialog.setCancelable(true);//按返回键取消窗体
dialog.setOnKeyListener(this);
dialog.setOnDismissListener(this);
Window window = dialog.getWindow();
if (window != null) {
window.setGravity(Gravity.BOTTOM);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//AndroidRuntimeException: requestFeature() must be called before adding content
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setContentView(contentLayout);
}
setSize(screenWidthPixels, WRAP_CONTENT);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldSetCancelable() {
Dialog dialog = new Dialog(context);
ShadowDialog shadow = shadowOf(dialog);
dialog.setCancelable(false);
assertThat(shadow.isCancelable()).isFalse();
}
代码示例来源:origin: FolioReader/FolioReader-Android
public static Dialog show(Context ctx, String text) {
final Dialog dialog = new Dialog(ctx, R.style.full_screen_dialog);
dialog.setContentView(R.layout.progress_dialog);
((TextView) dialog.findViewById(R.id.label_loading)).setText(text);
dialog.setCancelable(false);
dialog.show();
return dialog;
}
}
代码示例来源:origin: stackoverflow.com
final Dialog dialog=new Dialog(dialogactivity.this);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
代码示例来源:origin: michael-rapp/AndroidBottomSheet
@Override
public final void setCancelable(final boolean cancelable) {
super.setCancelable(cancelable);
this.cancelable = cancelable;
}
代码示例来源:origin: zzkong/BaseProject
public static Dialog showLoading(Activity context, String msg, boolean cancelable){
View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
TextView loadingText = (TextView) view.findViewById(R.id.id_tv_loading_dialog_text);
loadingText.setText(msg);
mLoadingDialog = new Dialog(context, R.style.CustomProgressDialog);
mLoadingDialog.setCancelable(cancelable);
mLoadingDialog.setCanceledOnTouchOutside(false);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
mLoadingDialog.show();
return mLoadingDialog;
}
代码示例来源:origin: stackoverflow.com
While creating your alert try
Dialog alertDialog = new Dialog(currentActivity);
alertDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.setCancelable(true);
WindowManager.LayoutParams WMLP = alertDialog.getWindow().getAttributes();
WMLP.x = 0;
WMLP.y = 0;
WMLP.dimAmount = 0.0f;
alertDialog .getWindow().setAttributes(WMLP);
代码示例来源:origin: huangfangyi/YiChat
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dialog = HTApp.getInstance().createLoadingDialog(getBaseActivity(),getString(R.string.now_refresh_msg));
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
}
代码示例来源:origin: jjdxmashl/jjdxm_dialogui
public static BuildBean setCancelable(BuildBean bean) {
if (bean.alertDialog != null) {
bean.alertDialog.setCancelable(bean.cancelable);
bean.alertDialog.setCanceledOnTouchOutside(bean.outsideTouchable);
} else if (bean.dialog != null) {
bean.dialog.setCancelable(bean.cancelable);
bean.dialog.setCanceledOnTouchOutside(bean.outsideTouchable);
}
return bean;
}
内容来源于网络,如有侵权,请联系作者删除!