当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.setCancelable方法代码示例

本文整理汇总了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;
}
 
开发者ID:nidhinvv,项目名称:BubbleAlert,代码行数:17,代码来源:BblDialogFragmentBase.java

示例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;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Tool.java

示例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);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:21,代码来源:BasicPopup.java

示例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;
}
 
开发者ID:AlphaBoom,项目名称:ClassifyView,代码行数:18,代码来源:IReaderClassifyView.java

示例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) {
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:UIs.java

示例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;
}
 
开发者ID:dufangyu1990,项目名称:JKApp,代码行数:29,代码来源:MyAlertDialog.java

示例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;
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:9,代码来源:DialogCreater.java

示例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;
}
 
开发者ID:LonelyMushroom,项目名称:LonelyM-ViewLib,代码行数:14,代码来源:DialogUpdateWidget.java

示例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() {

            }
        });
    }
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:50,代码来源:AjouteBranchActivity.java

示例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();

    }
 
开发者ID:maning0303,项目名称:MNProgressHUD,代码行数:32,代码来源:MStatusDialog.java

示例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;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:19,代码来源:LoadingDialog.java

示例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;
}
 
开发者ID:geniusforapp,项目名称:fancyDialog,代码行数:15,代码来源:FancyAlertDialog.java

示例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);

    }

}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:39,代码来源:WritePositionActivity.java

示例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;
}
 
开发者ID:Sayi,项目名称:RestClient,代码行数:16,代码来源:AddRestActivity.java

示例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;
}
 
开发者ID:marckregio,项目名称:maklib,代码行数:16,代码来源:DialogView.java


注:本文中的android.app.Dialog.setCancelable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。