@NonNull @Override @SuppressLint("InflateParams") public AppCompatDialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_sharelink, null, false); ButterKnife.bind(this, view); // build dialog AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.Widget_Proxy_App_Dialog) .setTitle(getString(R.string.dialog_sharelink_title)) .setView(view) .setPositiveButton(getString(R.string.share), _positiveClicked) .setNegativeButton(android.R.string.cancel, _negativeClicked) .create(); message.setText(getString(R.string.dialog_sharelink_message)); // Show the SW Keyboard on dialog start. Always. dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.getWindow().getAttributes().width = WindowManager.LayoutParams.MATCH_PARENT; dialog.setCanceledOnTouchOutside(false); return dialog; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { showImportAccountButton = AccountImporter.findAccounts(getActivity()).size() > 0; // setRetainInstance(true); // Build the dialog and set up the button click handlers AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_signin, null); ButterKnife.inject(this, view); builder.setView(view); builder.setTitle(getString(R.string.action_sign_in_short)); builder.setPositiveButton(getString(R.string.action_sign_in_short), null); if (showImportAccountButton) { builder.setNeutralButton(getString(R.string.import_account), null); } mImageViewShowPwd.setOnClickListener(ImgViewShowPasswordListener); SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUsername = mPrefs.getString(SettingsActivity.EDT_USERNAME_STRING, null); mPassword = mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, null); mOc_root_path = mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null); mCbDisableHostnameVerification = mPrefs.getBoolean(SettingsActivity.CB_DISABLE_HOSTNAME_VERIFICATION_STRING, false); // Set up the login form. mUsernameView.setText(mUsername); mPasswordView.setText(mPassword); mOc_root_path_View.setText(mOc_root_path); mCbDisableHostnameVerificationView.setChecked(mCbDisableHostnameVerification); mCbDisableHostnameVerificationView.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mPrefs .edit() .putBoolean(SettingsActivity.CB_DISABLE_HOSTNAME_VERIFICATION_STRING, isChecked) .commit(); } }); AlertDialog dialog = builder.create(); // Set dialog to resize when soft keyboard pops up dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return dialog; }
private void dialog_fail() { LayoutInflater inflater = LayoutInflater.from(this); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dialog_fail, null); AlertDialog adialog = new AlertDialog.Builder(ShenfenrezhengActivity.this).create(); adialog.show(); adialog.setContentView(layout); Window dialogWindow = adialog.getWindow(); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); dialogWindow.setBackgroundDrawableResource(android.R.color.transparent); dialogWindow.setGravity(Gravity.CENTER); // lp.x = 10; // 新位置X坐标 // lp.y = 345; // 新位置Y坐标 lp.width = 600; // 宽度 lp.height = 480; // 高度 dialogWindow.setAttributes(lp); }
private void setMood(int position) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle("Choose mood"); View view = ((Activity) context).getLayoutInflater().inflate(R.layout.dialog_listview, null); com.architjn.acjmusicplayer.utils.Mood mood = new com.architjn.acjmusicplayer.utils.Mood(); List<String> moods = mood.getAllMoods(); RecyclerView gv = (RecyclerView) view.findViewById(R.id.dialog_playlist_rv); LinearLayoutManager gridLayoutManager = new LinearLayoutManager(context); gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); gridLayoutManager.scrollToPosition(0); gv.setLayoutManager(gridLayoutManager); gv.setHasFixedSize(true); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialogBuilder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = alertDialogBuilder.create(); DialogMoodAdapter adapter = new DialogMoodAdapter(context, moods, data.get(position), dialog); gv.setAdapter(adapter); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.show(); }
private void changeSketchName() { String sketchPath = getGlobalState().getSketchPath(); int lastSlash = sketchPath.lastIndexOf('/'); final String sketchPathPrefix; if (lastSlash != -1) { // Include the slash at the end sketchPathPrefix = sketchPath.substring(0, lastSlash + 1); } else { sketchPathPrefix = ""; } AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle( String.format( Locale.US, getResources().getString(R.string.rename_sketch_title), getGlobalState().getSketchName())); alert.setMessage(R.string.rename_sketch_message); final EditText input = getGlobalState() .createAlertDialogEditText(this, alert, getGlobalState().getSketchName(), true); alert.setPositiveButton( R.string.rename, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String before = getGlobalState().getSketchName(); String after = input.getText().toString(); if (FileNavigatorAdapter.validateSketchName(after, SketchPropertiesActivity.this)) { switch (getGlobalState().getSketchLocationType()) { case SKETCHBOOK: getGlobalState() .getSketchLocation(sketchPathPrefix + before, APDE.SketchLocation.SKETCHBOOK) .renameTo( getGlobalState() .getSketchLocation( sketchPathPrefix + after, APDE.SketchLocation.SKETCHBOOK)); getGlobalState() .selectSketch(sketchPathPrefix + after, APDE.SketchLocation.SKETCHBOOK); // Make sure we save... saveSketch(); // Update the recent list getGlobalState() .putRecentSketch(APDE.SketchLocation.SKETCHBOOK, sketchPathPrefix + after); // We have to save before we do this... because it reads from the file system getGlobalState().getEditor().forceDrawerReload(); break; case EXTERNAL: getGlobalState() .getSketchLocation(sketchPathPrefix + before, APDE.SketchLocation.EXTERNAL) .renameTo( getGlobalState() .getSketchLocation( sketchPathPrefix + after, APDE.SketchLocation.EXTERNAL)); getGlobalState() .selectSketch(sketchPathPrefix + after, APDE.SketchLocation.EXTERNAL); // Make sure we save... saveSketch(); // Update the recent list getGlobalState() .putRecentSketch(APDE.SketchLocation.EXTERNAL, sketchPathPrefix + after); // We have to save before we do this... because it reads from the file system getGlobalState().getEditor().forceDrawerReload(); break; default: // Shouldn't happen... but Lint wants this here break; } // If the user has set the pretty name to the name of their sketch, they probably want // to change the pretty name too @SuppressWarnings("deprecation") EditTextPreference pref = ((EditTextPreference) findPreference("prop_pretty_name")); if (pref.getText().equals(before)) { pref.setText(after); } restartActivity(); } } }); alert.setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) {} }); // Show the soft keyboard if the hardware keyboard is unavailable (hopefully) AlertDialog dialog = alert.create(); if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getBoolean("use_hardware_keyboard", false)) dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show(); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Bundle bundle = getArguments(); final Alarm alarm = bundle.getParcelable(KEY_ALARM); final TimerObj timer = bundle.getParcelable(KEY_TIMER); final String tag = bundle.getString(KEY_TAG); final String label = savedInstanceState != null ? savedInstanceState.getString(KEY_LABEL) : bundle.getString(KEY_LABEL); final Context context = getActivity(); final int colorAccent = Utils.obtainStyledColor(context, R.attr.colorAccent, Color.RED); final int colorControlNormal = Utils.obtainStyledColor(context, R.attr.colorControlNormal, Color.WHITE); mLabelBox = new AppCompatEditText(context); mLabelBox.setOnEditorActionListener( new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { set(alarm, timer, tag); return true; } return false; } }); mLabelBox.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { final int color = TextUtils.isEmpty(s) ? colorControlNormal : colorAccent; mLabelBox.setSupportBackgroundTintList(ColorStateList.valueOf(color)); } @Override public void afterTextChanged(Editable editable) {} }); mLabelBox.setText(label); mLabelBox.selectAll(); final int padding = getResources().getDimensionPixelSize(R.dimen.label_edittext_padding); final AlertDialog alertDialog = new AlertDialog.Builder(context) .setView(mLabelBox, padding, 0, padding, 0) .setPositiveButton( R.string.time_picker_set, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { set(alarm, timer, tag); } }) .setNegativeButton( R.string.time_picker_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }) .setMessage(R.string.label) .create(); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); return alertDialog; }
// ........................................................................................... private void displyDialog(final int position) { LayoutInflater li = LayoutInflater.from(MainActivity.this); View promptsView = li.inflate(R.layout.prompt_indoor, null); android.support.v7.app.AlertDialog.Builder alertDialogBuilderMinPts = new android.support.v7.app.AlertDialog.Builder(MainActivity.this); // set prompts.xml to alertdialog builder alertDialogBuilderMinPts.setView(promptsView); final EditText userInput = (EditText) promptsView.findViewById(R.id.editText_dialog_info); final TextView textView = (TextView) promptsView.findViewById(R.id.textview_diaolg); if (position == 0) { textView.setText("Please Enter Minimum Duration For Secured Areas"); } else { textView.setText("Please Enter Minimum Distance For Secured Areas"); } // set dialog message alertDialogBuilderMinPts .setCancelable(true) .setPositiveButton( "Done", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, int id) { if (id == KeyEvent.KEYCODE_BACK) { dialog.dismiss(); } ParseQuery<ParseObject> query = ParseQuery.getQuery("Child"); if (status.equalsIgnoreCase("child")) { query.whereEqualTo("emailId", user.getUsername()); } else { query.whereEqualTo("parentEmailId", user.getUsername()); } query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { if (e == null) { ParseObject result = list.get(0); if (position == 0) { result.put("minDuration", userInput.getText().toString()); } else { result.put("minDistance", userInput.getText().toString()); } result.saveInBackground( new SaveCallback() { public void done(ParseException e) { if (e == null) { dialog.dismiss(); } else { // The save failed. } } }); } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText( MainActivity.this, R.string.error_internet_connection_database, Toast.LENGTH_LONG) .show(); } } }); } }); // create alert dialog android.support.v7.app.AlertDialog alertDialog = alertDialogBuilderMinPts.create(); // show it alertDialog.show(); alertDialog.getWindow().setLayout(1000, 1000); }
@Override public boolean onOptionsItemSelected(MenuItem item) { LayoutInflater layoutInflater = LayoutInflater.from(this); View dialog = null; switch (item.getItemId()) { case R.id.edit_title: // inflate layout with customized alert dialog view dialog = layoutInflater.inflate(R.layout.input_dialog, null); final AlertDialog.Builder editTitleDialogBuilder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); // customize alert dialog and set its view editTitleDialogBuilder.setTitle("Edit Title"); editTitleDialogBuilder.setIcon(R.drawable.ic_edit_black_24dp); editTitleDialogBuilder.setView(dialog); // fetch and set up edittext final EditText input = (EditText) dialog.findViewById(R.id.input_dialog_text); input.setText(ln.getName()); input.setFocusableInTouchMode(true); input.requestFocus(); // set up actions for dialog buttons editTitleDialogBuilder.setPositiveButton( "SAVE", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int whichButton) { ln.setName(input.getText().toString()); ln.updateDate(); getSupportActionBar().setTitle(Html.fromHtml("<b>" + ln.getName() + "</b>")); } }); editTitleDialogBuilder.setNegativeButton("CANCEL", null); // create and show the dialog AlertDialog editTitleDialog = editTitleDialogBuilder.create(); editTitleDialog.show(); // show keyboard editTitleDialog .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return true; case R.id.delete_note: // inflate layout with customized alert dialog view dialog = layoutInflater.inflate(R.layout.info_dialog, null); final AlertDialog.Builder deleteNoteDialogBuilder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); // customize alert dialog and set its view deleteNoteDialogBuilder.setTitle("Confirm Delete"); deleteNoteDialogBuilder.setIcon(R.drawable.ic_delete_black_24dp); deleteNoteDialogBuilder.setView(dialog); // fetch textview and set its text final TextView message = (TextView) dialog.findViewById(R.id.infodialog_text); message.setText("Are you sure you want to delete this list?"); deleteNoteDialogBuilder.setPositiveButton( "DELETE", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int whichButton) { Backend.getNotes().remove(ln); finish(); } }); deleteNoteDialogBuilder.setNegativeButton("CANCEL", null); // create and show the dialog AlertDialog deleteNoteDialog = deleteNoteDialogBuilder.create(); deleteNoteDialog.show(); return true; case android.R.id.home: this.finish(); return true; } return super.onOptionsItemSelected(item); }