List of usage examples for android.app Dialog setCanceledOnTouchOutside
public void setCanceledOnTouchOutside(boolean cancel)
From source file:com.app.blockydemo.ui.dialogs.ScriptNameDialog.java
@Override public Dialog onCreateDialog(Bundle bundle) { final View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_script_editor_name, null);/*from w w w.java 2 s. c o m*/ final Dialog dialogNewVariable = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.formula_editor_script_name) .setNegativeButton(R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleOkButton(dialogView); } }).create(); dialogNewVariable.setCanceledOnTouchOutside(true); dialogNewVariable.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialogNewVariable.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { handleOnShow(dialogNewVariable); } }); return dialogNewVariable; }
From source file:de.markusressel.android.tutorialtooltip.DialogFragmentTest.java
@NonNull @Override/*from w ww . j a v a 2 s .c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { // ask to really close final Dialog dialog = new Dialog(getActivity()) { @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { // When user touches the screen case MotionEvent.ACTION_DOWN: // Getting X coordinate float x = event.getX(); // Getting Y Coordinate float y = event.getY(); createTutorialTooltip(x, y); return true; } return super.onTouchEvent(event); } }; dialog.setTitle("Dialog Test"); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); // WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); // lp.copyFrom(dialog.getWindow().getAttributes()); //// lp.width = WindowManager.LayoutParams.MATCH_PARENT; //// lp.height = WindowManager.LayoutParams.WRAP_CONTENT; // dialog.show(); // dialog.getWindow().setAttributes(lp); dialog.show(); return dialog; }
From source file:com.app.blockydemo.ui.dialogs.NewVariableDialog.java
@Override public Dialog onCreateDialog(Bundle bundle) { final View dialogView = LayoutInflater.from(getActivity()) .inflate(R.layout.dialog_formula_editor_variable_name, null); final Dialog dialogNewVariable = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.formula_editor_variable_dialog_title) .setNegativeButton(R.string.cancel_button, new OnClickListener() { @Override// ww w . j a v a 2 s . c om public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleOkButton(dialogView); } }).create(); dialogNewVariable.setCanceledOnTouchOutside(true); dialogNewVariable.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialogNewVariable.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { handleOnShow(dialogNewVariable); } }); return dialogNewVariable; }
From source file:com.inter.trade.view.styleddialog.BaseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(getActivity(), R.style.SDL_Dialog); // custom dialog background final TypedArray a = getActivity().getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);/*from w ww . ja v a2 s. c om*/ Drawable dialogBackground = a.getDrawable(R.styleable.DialogStyle_dialogBackground); a.recycle(); dialog.getWindow().setBackgroundDrawable(dialogBackground); Bundle args = getArguments(); if (args != null) { dialog.setCanceledOnTouchOutside(args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE)); } return dialog; }
From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java
public void showActionSheet() { LayoutInflater inflater = LayoutInflater.from(getActivity()); final Dialog myDialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar); myDialog.setCanceledOnTouchOutside(true); myDialog.getWindow().setLayout(AbsoluteLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); myDialog.getWindow().setGravity(Gravity.BOTTOM); myDialog.getWindow().getAttributes().windowAnimations = R.anim.slide_up; WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.dimAmount = 0.75f;/*from www . j a v a 2 s . c o m*/ myDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.getWindow(); View dialoglayout = inflater.inflate(R.layout.dialog_profile_actionsheet, null); myDialog.setContentView(dialoglayout); TextView mTvTakeFromCamera = (TextView) myDialog.findViewById(R.id.tvTakeFromCamera); TextView mTvTakeFromLibrary = (TextView) myDialog.findViewById(R.id.tvTakeFromLibrary); long timestamp = System.currentTimeMillis(); AppData.getSingletonObject().setmFileTemp(getActivity(), "" + timestamp); mTvTakeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); takePicture(getActivity()); } }); mTvTakeFromLibrary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); openGallery(getActivity()); } }); TextView tvCancel = (TextView) myDialog.findViewById(R.id.tvCancel); tvCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); } }); try { myDialog.show(); } catch (WindowManager.BadTokenException e) { Log.e("", "View not attached."); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.sastra.app.timetable.TimetableActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.timetable_main); Log.d(TAG, "Entered On Create"); ActionBar Bar = getActionBar();/*from w w w. ja v a 2 s.c om*/ Bar.setLogo(R.drawable.ic_launcher_1); //Bar.setTitle(""); // String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/SASTRA Timetable/files/test.txt"; SharedPreferences mPreferences = this.getSharedPreferences("AB", MODE_PRIVATE); boolean firstTime = mPreferences.getBoolean("firstTime", true); if (firstTime) { SharedPreferences.Editor editor = mPreferences.edit(); editor.putBoolean("firstTime", false); editor.commit(); Dialog d2 = new Dialog(this); d2.setTitle("HELP"); d2.setCanceledOnTouchOutside(true); TextView tv = new TextView(this); tv.setText( "This application can be used to store your timetable.First,click on Manage Subjects Icon(Wrench Icon) inorder to add all your subjects.Click on Add Subjects on top and enter the details of your subject.The fields that appear are optional and not manditory.Once you have added all the subjects,go back to the main screen and click on Add Classes icon(Plus Icon) to add the different classes to your timetable.The fields that appear are again optional and all of them need not be filled.You can long press on any particular subject to edit or delete them.You can delete all the informations using Delete All(Garbage Icon) option."); ScrollView sav = new ScrollView(this); sav.addView(tv); LayoutParams lap = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); d2.addContentView(sav, lap); d2.show(); } boolean enabled = true; Bar.setHomeButtonEnabled(enabled); //File database=getApplicationContext().getDatabasePath("massey.db"); // if (database.exists()) { data = new InternalDB(this); // } // add fragments mFragments = new ArrayList<Fragment>(); mFragments.add(Fragment.instantiate(this, MONDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, TUESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, WEDNESDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, THURSDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, FRIDAYFRAGMENT)); mFragments.add(Fragment.instantiate(this, SATURDAYFRAGMENT)); // adapter mAdapter = new MainPagerAdapter(getSupportFragmentManager(), mFragments); // pager mPager = (ViewPager) findViewById(R.id.view_pager); mPager.setAdapter(mAdapter); // indicator mIndicator = (TitlePageIndicator) findViewById(R.id.title_indicator); //mIndicator.setBackgroundColor(0x0106000e); //mIndicator.setFooterColor(0xffffff); mIndicator.setTextColor(0xFF000000); mIndicator.setSelectedColor(0xFF000000); mIndicator.setViewPager(mPager); intent = new Intent(getApplicationContext(), AddSubjects.class);//intent = new Intent(getApplicationContext(), AddSubjects.class); builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to delete all lessons?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteAllHours(); data.close(); // update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert = builder.create(); builder2 = new AlertDialog.Builder(this); builder2.setMessage("Are you sure you want to delete this lesson?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { data.open(); data.deleteHour(OLDSName, OLDHDay, OLDHType, OLDHClass, OLDHStart, OLDHEnd); data.close(); //update(); mAdapter.notifyDataSetChanged(); mAdapter.finishUpdate(mPager); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert2 = builder2.create(); //added addDialog = new Dialog(this); addDialog.setCancelable(false); action = "insert"; addDialog.setTitle("Add Class"); addDialog.setContentView(R.layout.timetable_addhour); HType = (EditText) addDialog.findViewById(R.id.typeEdit); HClass = (EditText) addDialog.findViewById(R.id.classroomEdit); arraydays = new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; HDay = (Spinner) addDialog.findViewById(R.id.day); arrayadapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arraydays); arrayadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); HDay.setAdapter(arrayadapter); HDay.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedDay = arraydays[position]; } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); fromDialog = new TimePickerDialog(this, fromTimeSetListener, 12, 0, true); toDialog = new TimePickerDialog(this, toTimeSetListener, 12, 0, true); //This place is important. SName = (Spinner) addDialog.findViewById(R.id.SName); SName.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { selectedSubject = (String) arraySubjects[position]; Log.d("AB", "We are inside the setOnItemSelectedListener for Sname : 264"); Log.d("AB", selectedSubject); } public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); Button buttonFrom = (Button) addDialog.findViewById(R.id.buttonFrom); buttonFrom.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { fromDialog.show(); } }); Button buttonTo = (Button) addDialog.findViewById(R.id.buttonTo); buttonTo.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toDialog.show(); } }); start = (TextView) addDialog.findViewById(R.id.start); end = (TextView) addDialog.findViewById(R.id.end); Button cancel = (Button) addDialog.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); } }); Button ok = (Button) addDialog.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { int HDay = SDay2IDay(selectedDay); if (action.equals("insert")) { data.open(); data.insertIntoHours(selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } else if (action.equals("edit")) { data.open(); data.updateHours(OLDSName, OLDHType, OLDHClass, OLDHDay, OLDHStart, OLDHEnd, selectedSubject, HDay, HType.getText().toString(), HClass.getText().toString(), start.getText().toString(), end.getText().toString()); data.close(); } addDialog.cancel(); fromDialog.updateTime(12, 0); toDialog.updateTime(12, 0); start.setText("--:--"); end.setText("--:--"); HType.setText(null); HClass.setText(null); mAdapter.notifyDataSetChanged(); //update(); mAdapter.finishUpdate(mPager); } }); }
From source file:org.catrobat.catroid.ui.dialogs.UploadProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_upload_project, null); projectRename = (TextView) dialogView.findViewById(R.id.tv_project_rename); projectDescriptionField = (EditText) dialogView.findViewById(R.id.project_description_upload); projectUploadName = (EditText) dialogView.findViewById(R.id.project_upload_name); sizeOfProject = (TextView) dialogView.findViewById(R.id.dialog_upload_size_of_project); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.upload_project_dialog_title) .setPositiveButton(R.string.upload_button, new DialogInterface.OnClickListener() { @Override/*from w w w .j av a 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { handleUploadButtonClick(); } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleCancelButtonClick(); } }).create(); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { initListeners(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT); } }); initControls(); return dialog; }
From source file:com.nanostuffs.yurdriver.fragment.RegisterFragment.java
private void datepicker() { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.datepicker_layout); final DatePicker date = (DatePicker) dialog.findViewById(R.id.datePicker1); final Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -1 * (16 * 365)); date.setMaxDate(c.getTimeInMillis()); Button text = (Button) dialog.findViewById(R.id.ok); text.setOnClickListener(new OnClickListener() { @Override//from w w w .j av a2 s . com public void onClick(View v) { v.bringToFront(); String dateString = String .valueOf(date.getYear() + "-" + (date.getMonth() + 1) + "-" + date.getDayOfMonth()); etDOB.setText(dateString); dialog.dismiss(); } }); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub v.bringToFront(); dialog.dismiss(); } }); dialog.show(); }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void confirmSendLog() { CommonLogUtil.flushLog(mContext, mGp); mThemeColorList = ThemeUtil.getThemeColorList(getActivity()); createTempLogFile();//from w w w . ja v a 2 s. c o m final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_send_log_dlg); dialog.setCanceledOnTouchOutside(false); LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.confirm_send_log_dlg_title_view); title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color); TextView title = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_title); title.setTextColor(mThemeColorList.text_color_dialog_title); TextView msg = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_msg); msg.setTextColor(mThemeColorList.text_color_info); msg.setBackgroundColor(mThemeColorList.dialog_msg_background_color); final Button btn_ok = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_cancel_btn); final Button btn_preview = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_preview); CommonDialog.setDlgBoxSizeLimit(dialog, false); btn_preview.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + mGp.getLogDirName() + "temp_log.txt"), "text/plain"); startActivity(intent); } }); btn_ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { sendLogFileToDeveloper(mGp.getLogDirName() + "temp_log.txt"); dialog.dismiss(); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setCanceledOnTouchOutside(true); return dialog; }