本文整理汇总了Java中android.app.Dialog.setCancelable方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setCancelable方法的具体用法?Java Dialog.setCancelable怎么用?Java Dialog.setCancelable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Dialog
的用法示例。
在下文中一共展示了Dialog.setCancelable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateDialog
import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getActivity());
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.setOnDismissListener(this);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
return dialog;
}
示例2: buildDialog
import android.app.Dialog; //导入方法依赖的package包/类
public static Dialog buildDialog(Context context, boolean cancleable, boolean outsideTouchable) {
if (context instanceof Activity){//todo keycode
Activity activity = (Activity) context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity.isDestroyed()){
context = StyledDialog.context;
}
}
}
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(cancleable);
dialog.setCanceledOnTouchOutside(outsideTouchable);
return dialog;
}
示例3: initDialog
import android.app.Dialog; //导入方法依赖的package包/类
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);
}
示例4: createSubDialog
import android.app.Dialog; //导入方法依赖的package包/类
@Override
protected Dialog createSubDialog() {
Dialog dialog = new Dialog(getContext(), R.style.SubDialogStyle);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes();
layoutParams.gravity = Gravity.BOTTOM;
layoutParams.height = getHeight();
layoutParams.dimAmount = 0.6f;
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
layoutParams.format = PixelFormat.TRANSPARENT;
layoutParams.windowAnimations = R.style.BottomDialogAnimation;
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
return dialog;
}
示例5: call
import android.app.Dialog; //导入方法依赖的package包/类
public static void call(Activity activity, String message, OnClickListener yes, boolean cancelable) {
if (activity != null) {
Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(message).setPositiveButton(2131100002, yes).create();
dialog.setCancelable(cancelable);
if (!activity.isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例6: builder
import android.app.Dialog; //导入方法依赖的package包/类
public MyAlertDialog builder() {
// 获取Dialog布局
View view = LayoutInflater.from(context).inflate(
R.layout.view_alertdialog, null);
// 获取自定义Dialog布局中的控件
lLayout_bg = (LinearLayout) view.findViewById(R.id.lLayout_bg);
txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title.setVisibility(View.GONE);
txt_msg = (TextView) view.findViewById(R.id.txt_msg);
txt_msg.setVisibility(View.GONE);
btn_neg = (Button) view.findViewById(R.id.btn_neg);
btn_neg.setVisibility(View.GONE);
btn_pos = (Button) view.findViewById(R.id.btn_pos);
btn_pos.setVisibility(View.GONE);
img_line = (ImageView) view.findViewById(R.id.img_line);
img_line.setVisibility(View.GONE);
// 定义Dialog布局和参数
dialog = new Dialog(context, R.style.AlertDialogStyle);
dialog.setContentView(view);
dialog.setCancelable(false);
// 调整dialog背景大小
lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));
return this;
}
示例7: getDialog
import android.app.Dialog; //导入方法依赖的package包/类
private static Dialog getDialog(Context context, int layoutId) {
Dialog dialog = new Dialog(context, R.style.defaultDialogStyle);
dialog.setContentView(layoutId);
dialog.getWindow().getAttributes().gravity = Gravity.CENTER; //居中
dialog.setCanceledOnTouchOutside(true); //点击空白不取消
dialog.setCancelable(false); //点击返回按钮不取消
return dialog;
}
示例8: createDialog
import android.app.Dialog; //导入方法依赖的package包/类
public Dialog createDialog(Context context,boolean isCancel) {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_update, null);// 得到加载view
progressBar = (NumberProgressBar) view.findViewById(R.id.progress_bar);
dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //http://blog.csdn.net/u011747761/article/details/47419419
dialog.setCancelable(isCancel);
dialog.setCanceledOnTouchOutside(isCancel);
dialog.show();
dialog.addContentView(view, new RelativeLayout.LayoutParams(
DensityConversionUtil.dpToPx(context, 250),
DensityConversionUtil.dpToPx(context, 100)));
return dialog;
}
示例9: addBranch
import android.app.Dialog; //导入方法依赖的package包/类
private void addBranch() {
final Dialog pd = new Dialog(this);
pd.setCancelable(false);
pd.setContentView(R.layout.adding_loading_popup);
pd.show();
Branch branch = new Branch();
if( textInput_nom.getEditText() != null &&
textInput_tel.getEditText() != null &&
textInput_addresse.getEditText() != null) {
branch.setBrName(textInput_nom.getEditText().getText().toString());
branch.setBrTel(textInput_tel.getEditText().getText().toString());
branch.setBrAddress(textInput_addresse.getEditText().getText().toString());
//Call the API
BranchesNetworkCalls.addBranch(branch).subscribe(new Observer<Boolean>() {
@Override
public void onSubscribe(Disposable d) {
compositeDisposable.add(d);
}
//Called when the request succeed
@Override
public void onNext(Boolean value) {
//Value is the return of the API call
//In this case it is the Branch ID
//For more info see Mohammad faour's code (ManagedObjects/ClientController.java)
Log.i("Add Branch" , "Branch added successfully");
Toast.makeText(AjouteBranchActivity.this , "Branch added successfully" , Toast.LENGTH_SHORT).show();
AjouteBranchActivity.this.finish();
}
//Called if the request fail
@Override
public void onError(Throwable e) {
Log.e("Add Branch" , "Error adding new Branch" , e);
if(e instanceof SocketException || e instanceof IOException) {
Toast.makeText(AjouteBranchActivity.this , R.string.no_internet , Toast.LENGTH_SHORT).show();
} else if (e instanceof Exception) {
Toast.makeText(AjouteBranchActivity.this , e.getMessage() , Toast.LENGTH_LONG).show();
}
}
@Override
public void onComplete() {
}
});
}
}
示例10: initDialog
import android.app.Dialog; //导入方法依赖的package包/类
private void initDialog() {
LayoutInflater inflater = LayoutInflater.from(mContext);
View mProgressDialogView = inflater.inflate(R.layout.mn_status_dialog_layout, null);// 得到加载view
mDialog = new Dialog(mContext, R.style.MNCustomDialog);// 创建自定义样式dialog
mDialog.setCancelable(false);// 不可以用“返回键”取消
mDialog.setCanceledOnTouchOutside(false);
mDialog.setContentView(mProgressDialogView);// 设置布局
//设置整个Dialog的宽高
DisplayMetrics dm = new DisplayMetrics();
WindowManager windowManager = ((Activity) mContext).getWindowManager();
windowManager.getDefaultDisplay().getMetrics(dm);
int screenW = dm.widthPixels;
int screenH = dm.heightPixels;
WindowManager.LayoutParams layoutParams = mDialog.getWindow().getAttributes();
layoutParams.width = screenW;
layoutParams.height = screenH;
mDialog.getWindow().setAttributes(layoutParams);
//获取布局
dialog_window_background = (RelativeLayout) mProgressDialogView.findViewById(R.id.dialog_window_background);
dialog_view_bg = (RelativeLayout) mProgressDialogView.findViewById(R.id.dialog_view_bg);
imageStatus = (ImageView) mProgressDialogView.findViewById(R.id.imageStatus);
tvShow = (TextView) mProgressDialogView.findViewById(R.id.tvShow);
//默认配置
configView();
}
示例11: showDialogForLoading
import android.app.Dialog; //导入方法依赖的package包/类
/**
* 显示加载对话框
* @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;
}
示例12: onCreateDialog
import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
if (builder != null) {
dialog.setCancelable(builder.isCancelable());
instance.setCancelable(builder.isCancelable());
}
return dialog;
}
示例13: onViewClicked
import android.app.Dialog; //导入方法依赖的package包/类
@OnClick(R.id.activity_write_position_keep)
public void onViewClicked() {
progressDialog = new Dialog(WritePositionActivity.this,R.style.progress_dialog);
progressDialog.setContentView(R.layout.dialog);
progressDialog.setCancelable(true);
progressDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
TextView msg = (TextView) progressDialog.findViewById(R.id.id_tv_loadingmsg);
msg.setText("卖力上传中");
progressDialog.show();
StringBuilder builder = new StringBuilder();
StringBuilder builders = new StringBuilder();
String sqlresult;
name="'"+activityWritePositionName.getText().toString().trim()+"'";
number="'"+activityWritePositionNumber.getText().toString().trim()+"'";
pos="'"+activityWritePositionPos.getText().toString().trim()+"'";
if (isChecked){
builder.append("INSERT into position value(").append(username).append(",").append(name).append(",").append(number).append(",").append(pos)
.append(") ON DUPLICATE KEY UPDATE").append(" name=").append(name).append(",number=").append(number).append(",positions=")
.append(pos).append(";");
builders.append("INSERT into positions value(").append("null,").append(username).append(",").append(name).append(",").append(number).append(",").append(pos).append(");");
sqlresult=String.valueOf(builder);
String sqlresults=String.valueOf(builders);
Log.i("builder",sqlresult);
Log.i("builder",sqlresults);
send(sqlresult,sqlresults);
}else{
builders.append("INSERT into positions value(").append("null,").append(username).append(",").append(name).append(",").append(number).append(",").append(pos).append(");");
sqlresult=String.valueOf(builders);
Log.i("builder",sqlresult);
send(sqlresult);
}
}
示例14: createProgressDialog
import android.app.Dialog; //导入方法依赖的package包/类
private Dialog createProgressDialog(String msg) {
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.sending);
abortView = (TextView) dialog.findViewById(R.id.abort);
abortView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != presenter) presenter.abortRequest();
}
});
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
return dialog;
}
示例15: showSigninDialog
import android.app.Dialog; //导入方法依赖的package包/类
public Dialog showSigninDialog() {
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(1);
dialog.setCancelable(true);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
dialog.setContentView(R.layout.dialog_alert);
dialog.show();
((TextView) dialog.findViewById(R.id.exit)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
return dialog;
}