Java Code Examples for android.app.Dialog#setCancelable()
The following examples show how to use
android.app.Dialog#setCancelable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogCreator.java From jmessage-android-uikit with MIT License | 6 votes |
public static Dialog createLongPressMessageDialog(Context context, String title, boolean hide, View.OnClickListener listener){ AlertDialog.Builder builder = new AlertDialog.Builder(context); View view = LayoutInflater.from(context).inflate(IdHelper.getLayout(context, "jmui_dialog_msg_alert"), null); builder.setView(view); Button copyBtn = (Button) view.findViewById(IdHelper.getViewID(context, "jmui_copy_msg_btn")); Button forwardBtn = (Button) view.findViewById(IdHelper.getViewID(context, "jmui_forward_msg_btn")); View line1 = view.findViewById(IdHelper.getViewID(context, "jmui_forward_split_line")); View line2 = view.findViewById(IdHelper.getViewID(context, "jmui_delete_split_line")); Button deleteBtn = (Button) view.findViewById(IdHelper.getViewID(context, "jmui_delete_msg_btn")); final TextView titleTv = (TextView) view.findViewById(IdHelper.getViewID(context, "jmui_dialog_title")); if (hide) { copyBtn.setVisibility(View.GONE); forwardBtn.setVisibility(View.GONE); line1.setVisibility(View.GONE); line2.setVisibility(View.GONE); } titleTv.setText(title); final Dialog dialog = builder.create(); copyBtn.setOnClickListener(listener); forwardBtn.setOnClickListener(listener); deleteBtn.setOnClickListener(listener); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); return dialog; }
Example 2
Source File: DialogPicChooser.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
private void init(Context context) { View view = LayoutInflater.from(context).inflate( R.layout.z_dialog_pic_chooser, null); dialog = new Dialog(context, R.style.Dialog_General); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(view); Window window = dialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; window.setWindowAnimations(R.style.AnimUpDown); view.findViewById(R.id.btn_cancel).setOnClickListener(this); view.findViewById(R.id.tv_camera).setOnClickListener(this); view.findViewById(R.id.tv_gallery).setOnClickListener(this); }
Example 3
Source File: DialogUitls.java From Instagram-Profile-Downloader with MIT License | 6 votes |
public static void infoPopupForCloseActivity(final Activity activity, String message, String buttonName) { final Dialog dialog = new Dialog(activity); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.custom_dialog); dialog.getWindow().getAttributes().windowAnimations = R.style.animationdialog; dialog.setCancelable(true); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Window window = dialog.getWindow(); window.setGravity(Gravity.CENTER); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView btnTxt = (TextView) dialog.findViewById(R.id.txtOK); TextView txt = (TextView) dialog.findViewById(R.id.txt); txt.setText(message); btnTxt.setText(buttonName); btnTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); activity.finish(); } }); dialog.show(); }
Example 4
Source File: DialogCreator.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public static Dialog createDeleteMessageDialog(Context context, View.OnClickListener listener) { Dialog dialog = new Dialog(context, IdHelper.getStyle(context, "jmui_default_dialog_style")); LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(IdHelper.getLayout(context, "jmui_dialog_base_with_button"), null); dialog.setContentView(v); TextView title = (TextView) v.findViewById(IdHelper.getViewID(context, "jmui_title")); title.setText(IdHelper.getString(context, "jmui_clear_history_confirm_title")); final Button cancel = (Button) v.findViewById(IdHelper.getViewID(context, "jmui_cancel_btn")); final Button commit = (Button) v.findViewById(IdHelper.getViewID(context, "jmui_commit_btn")); commit.setText(IdHelper.getString(context, "jmui_confirm")); cancel.setOnClickListener(listener); commit.setOnClickListener(listener); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); return dialog; }
Example 5
Source File: Util.java From Track-My-Location with GNU General Public License v3.0 | 6 votes |
public static boolean checkGooglePlayServicesAvailability(Activity activity) { GoogleApiAvailability api = GoogleApiAvailability.getInstance(); int resultCode = api.isGooglePlayServicesAvailable(activity); if (resultCode != ConnectionResult.SUCCESS) { if (api.isUserResolvableError(resultCode)) { Dialog dialog = api.getErrorDialog(activity, resultCode, 1234); dialog.setCancelable(false); dialog.setOnCancelListener(dialogInterface -> activity.finish()); dialog.show(); } else { Toast.makeText(activity, "Device unsupported", Toast.LENGTH_LONG).show(); activity.finish(); } return false; } return true; }
Example 6
Source File: DialogImgMode.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
private void init(Context context) { View view = LayoutInflater.from(context).inflate( R.layout.z_dialog_img_mode, null); dialog = new Dialog(context, R.style.Dialog_General); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(view); Window window = dialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; window.setWindowAnimations(R.style.AnimUpDown); view.findViewById(R.id.btn_cancel).setOnClickListener(this); view.findViewById(R.id.tv_high).setOnClickListener(this); view.findViewById(R.id.tv_low).setOnClickListener(this); view.findViewById(R.id.tv_none).setOnClickListener(this); }
Example 7
Source File: CheckUpdata.java From Android with MIT License | 6 votes |
private void showUpdataDialog(final Connect.VersionResponse versionResponse) { boolean isCancle = versionResponse.getForce(); Dialog dialogUpdata = DialogUtil.showAlertTextView(activity, activity.getResources().getString(R.string.Set_Found_new_version), versionResponse.getRemark(), "", activity.getResources().getString(R.string.Set_Now_update_app), isCancle, new DialogUtil.OnItemClickListener() { @Override public void confirm(String value) { if (!TextUtils.isEmpty(versionResponse.getUpgradeUrl())) { downLoadpath = versionResponse.getUpgradeUrl(); PermissiomUtilNew.getInstance().requestPermissom(activity, new String[]{PermissiomUtilNew.PERMISSIM_STORAGE}, permissomCallBack); } } @Override public void cancel() { } }, false); if (isCancle) { dialogUpdata.setCancelable(false); } }
Example 8
Source File: iOSDialog.java From iOSDialog with MIT License | 6 votes |
public iOSDialog(Context context, String title, String subtitle, boolean bold, Typeface typeFace,boolean cancelable) { negativeExist=false; dialog = new Dialog(context); dialog.setContentView(R.layout.alerts_two_buttons); if(dialog.getWindow()!=null) dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); initViews(); dialog.setCancelable(cancelable); setTitle(title); setSubtitle(subtitle); setBoldPositiveLabel(bold); setTypefaces(typeFace); initEvents(); }
Example 9
Source File: BasicPopup.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
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); }
Example 10
Source File: ClassifyView.java From ClassifyView with Apache License 2.0 | 6 votes |
/** * 创建次级目录的弹窗 * 可以重写该方法修改弹窗的样式 及 动画 * 注意添加自定义View是无效的 * 自定义View需要重写{@link #getSubContent()} * * @return */ protected Dialog createSubDialog() { Dialog dialog = new Dialog(getContext(), R.style.ClassifyViewTheme); 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 = (int) (getHeight() * mSubRatio); layoutParams.dimAmount = 0.6f; layoutParams.windowAnimations = R.style.DefaultAnimation; layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; layoutParams.flags |= WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); return dialog; }
Example 11
Source File: MultipleDaysFragment.java From weather with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(lp); return dialog; }
Example 12
Source File: NoteFilterActivity.java From financisto with GNU General Public License v2.0 | 5 votes |
@Override protected Dialog onCreateDialog(final int id) { final Dialog d = new Dialog(this); d.setCancelable(true); d.setTitle(R.string.note_text_containing); d.setContentView(R.layout.filter_period_select); Button bOk = d.findViewById(R.id.bOK); bOk.setOnClickListener(v -> d.dismiss()); Button bCancel = d.findViewById(R.id.bCancel); bCancel.setOnClickListener(v -> d.cancel()); return d; }
Example 13
Source File: DialogOverlayCore.java From 365browser with Apache License 2.0 | 5 votes |
/** * Finish init on the proper thread. We'll use this thread for the Dialog Looper thread. * @param dialog the dialog, which uses our current thread as the UI thread. * @param config initial config. * @param host host interface, for sending messages that (probably) need to thread hop. */ public void initialize(Context context, AndroidOverlayConfig config, Host host) { mHost = host; mDialog = new Dialog(context, android.R.style.Theme_NoDisplay); mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mDialog.setCancelable(false); mLayoutParams = createLayoutParams(config.secure); copyRectToLayoutParams(config.rect); }
Example 14
Source File: FingerPrintActivity.java From AndroidDemo with MIT License | 5 votes |
private void useKeyboard() { if (fingerPrintIsUsable) cancellationSignal.cancel(); View view = LayoutInflater.from(this).inflate(R.layout.listformat_dialog_usepwd, null); ImageButton ib_close = (ImageButton) view.findViewById(R.id.ib_close); final PwdEditText pwdEditText = (PwdEditText) view.findViewById(R.id.pwdEditText); keyDialog = new Dialog(this); keyDialog.setContentView(view); keyDialog.setCancelable(true); keyDialog.setCanceledOnTouchOutside(false); ib_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { keyDialog.dismiss(); } }); keyDialog.show(); pwdEditText.setOnFinishListener(new PwdEditText.OnFinishListener() { @Override public void onFinish(String pwd) { Toast.makeText(FingerPrintActivity.this, "PassWord:" + pwd, Toast.LENGTH_SHORT).show(); imm.hideSoftInputFromWindow(pwdEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); handler.sendEmptyMessageDelayed(0x003, 1000); } }); }
Example 15
Source File: DialogCreator.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public static Dialog createDelRecommendDialog(Context context, View.OnClickListener listener) { Dialog dialog = new Dialog(context, IdHelper.getStyle(context, "jmui_default_dialog_style")); View v = LayoutInflater.from(context).inflate( IdHelper.getLayout(context, "jmui_dialog_del_recommend"), null); dialog.setContentView(v); final LinearLayout deleteLl = (LinearLayout) v.findViewById(IdHelper .getViewID(context, "jmui_del_recommend_ll")); deleteLl.setOnClickListener(listener); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); return dialog; }
Example 16
Source File: Custom_chooser.java From Android-Example with Apache License 2.0 | 4 votes |
public void show_custom_chooser() { // TODO Auto-generated method stub final Dialog dialog = new Dialog(Custom_chooser.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes(); WMLP.gravity = Gravity.CENTER; dialog.getWindow().setAttributes(WMLP); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.about_dialog); dialog.setCancelable(true); ListView lv=(ListView)dialog.findViewById(R.id.listView1); PackageManager pm=getPackageManager(); email.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); email.putExtra(Intent.EXTRA_SUBJECT, "Hi"); email.putExtra(Intent.EXTRA_TEXT, "Hi,This is Test"); email.setType("text/plain"); List<ResolveInfo> launchables=pm.queryIntentActivities(email, 0); Collections.sort(launchables, new ResolveInfo.DisplayNameComparator(pm)); adapter=new AppAdapter(pm, launchables); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub ResolveInfo launchable=adapter.getItem(position); ActivityInfo activity=launchable.activityInfo; ComponentName name=new ComponentName(activity.applicationInfo.packageName, activity.name); email.addCategory(Intent.CATEGORY_LAUNCHER); email.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); email.setComponent(name); startActivity(email); } }); dialog.show(); }
Example 17
Source File: MainActivity.java From Android with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); MobileAds.initialize(this, "ca-app-pub-3341550634619945~1422870532"); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/brownregular.ttf") .setFontAttrId(R.attr.fontPath) .build() ); prefs = getSharedPreferences("Plex", Activity.MODE_PRIVATE); editor = prefs.edit(); mContext = MainActivity.this; btn_one = findViewById(R.id.btn_one); btn_two = findViewById(R.id.btn_two); btn_three = findViewById(R.id.btn_three); btn_four = findViewById(R.id.btn_four); btn_five = findViewById(R.id.btn_five); btn_one.setOnClickListener(this); btn_two.setOnClickListener(this); btn_three.setOnClickListener(this); btn_four.setOnClickListener(this); btn_five.setOnClickListener(this); upadate_retrofit(); get_API_keys(); analytics(); if(!isPackageInstalled()){ final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.alertdialog_update); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setCancelable(true); dialog.show(); Button update_btn = dialog.findViewById(R.id.update_btn); TextView title_view = dialog.findViewById(R.id.title); TextView message_update = dialog.findViewById(R.id.message_update); ImageView background_image = dialog.findViewById(R.id.background_image); background_image.setImageResource(R.drawable.mxplayer); title_view.setText(""); message_update.setText("For better streaming quality and subtitle \nDownload MX Player app"); update_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); final String appPackageName = "com.mxtech.videoplayer.ad"; // getPackageName() from Context or Activity object try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); } } }); } }
Example 18
Source File: CordovaActivity.java From reader with MIT License | 4 votes |
/** * Shows the splash screen over the full Activity */ @SuppressWarnings("deprecation") protected void showSplashScreen(final int time) { final CordovaActivity that = this; Runnable runnable = new Runnable() { public void run() { // Get reference to display Display display = getWindowManager().getDefaultDisplay(); // Create the layout for the dialog LinearLayout root = new LinearLayout(that.getActivity()); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); root.setBackgroundResource(that.splashscreen); // Create and show the dialog splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, time); } }; this.runOnUiThread(runnable); }
Example 19
Source File: CordovaActivity.java From CordovaYoutubeVideoPlayer with MIT License | 4 votes |
/** * Shows the splash screen over the full Activity */ @SuppressWarnings("deprecation") protected void showSplashScreen(final int time) { final CordovaActivity that = this; Runnable runnable = new Runnable() { public void run() { // Get reference to display Display display = getWindowManager().getDefaultDisplay(); // Create the layout for the dialog LinearLayout root = new LinearLayout(that.getActivity()); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); root.setBackgroundResource(that.splashscreen); // Create and show the dialog splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, time); } }; this.runOnUiThread(runnable); }
Example 20
Source File: UpdateManager.java From BigApp_Discuz_Android with Apache License 2.0 | 4 votes |
public void showNoticeDialog(final Context context, final UpdateResponse response) { if(response != null && TextUtils.isEmpty(response.path)){ return; } StringBuilder updateMsg = new StringBuilder(); updateMsg.append(response.version); updateMsg.append(context.getString(R.string.analysissdk_update_new_impress)); updateMsg.append("\n"); updateMsg.append(response.content); updateMsg.append("\n"); updateMsg.append(context.getString(R.string.analysissdk_update_apk_size, sizeToString(response.size))); final Dialog dialog = new Dialog(context, R.style.AnalysisSDK_CommonDialog); dialog.setContentView(R.layout.analysissdk_update_notify_dialog); TextView tvContent = (TextView) dialog.findViewById(R.id.update_tv_dialog_content); tvContent.setMovementMethod(ScrollingMovementMethod.getInstance()); tvContent.setText(updateMsg); final CheckBox cBox = (CheckBox) dialog.findViewById(R.id.update_cb_ignore); if(UpdateConfig.isUpdateForce()){ cBox.setVisibility(View.GONE); }else { cBox.setVisibility(View.VISIBLE); } android.view.View.OnClickListener ocl = new android.view.View.OnClickListener() { public void onClick(View v) { if(v.getId() == R.id.update_btn_dialog_ok){ dialogBtnClick = UpdateStatus.Update; }else if(v.getId() == R.id.update_btn_dialog_cancel){ if(cBox.isChecked()){ dialogBtnClick = UpdateStatus.Ignore; } } dialog.dismiss(); UpdateAgent.updateDialogDismiss(context, dialogBtnClick, response); } }; dialog.findViewById(R.id.update_btn_dialog_ok).setOnClickListener(ocl); dialog.findViewById(R.id.update_btn_dialog_cancel).setOnClickListener(ocl); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(true); dialog.show(); }