Java Code Examples for androidx.appcompat.app.AlertDialog#Builder
The following examples show how to use
androidx.appcompat.app.AlertDialog#Builder .
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: SettingsScreen.java From adamant-android with GNU General Public License v3.0 | 6 votes |
@Override public void showVerifyingDialog() { AlertDialog.Builder builder = null; FragmentActivity activity = getActivity(); if (activity != null) { builder = new AlertDialog.Builder(activity); builder.setMessage(R.string.fragment_settings_tee_verifying); verifyingDialog = builder.create(); verifyingDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Flowable .interval(500, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.computation()) .take(1) .observeOn(AndroidSchedulers.mainThread()) .doOnComplete(() -> presenter.onVerifyTee()) .subscribe(); } }); verifyingDialog.show(); } }
Example 2
Source File: MainActivity.java From tap-android-sdk with Apache License 2.0 | 6 votes |
private void askModeDialog(DialogInterface.OnClickListener textModeListener, DialogInterface.OnClickListener controllerWithMouseHIDListener, DialogInterface.OnClickListener controllerWithoutMouseHIDListener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Change TAP Mode"); // builder.setMessage("Would you like to continue learning how to use Android alerts?"); // add the buttons if (textModeListener != null) { builder.setNeutralButton("Text", textModeListener); } if (controllerWithMouseHIDListener != null) { builder.setNeutralButton("Con w/", controllerWithMouseHIDListener); } if (controllerWithoutMouseHIDListener != null) { builder.setNeutralButton("Con w/o", controllerWithoutMouseHIDListener); } builder.setNegativeButton("Cancel", null); // create and show the alert dialog AlertDialog dialog = builder.create(); dialog.show(); }
Example 3
Source File: FirstRunDialogFragment.java From Notepad with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.first_run) .setTitle(R.string.app_name) .setPositiveButton(R.string.action_close, (dialog, id) -> listener.onFirstRunDialogPositiveClick()); // Prevent the user from cancelling this particular dialog setCancelable(false); // Create the AlertDialog object and return it return builder.create(); }
Example 4
Source File: FragmentWalletsAbstract.java From Lunary-Ethereum-Wallet with GNU General Public License v3.0 | 6 votes |
public void generateDialog() { if (!Settings.walletBeingGenerated) { Intent genI = new Intent(ac, WalletGenActivity.class); ac.startActivityForResult(genI, WalletGenActivity.REQUEST_CODE); } else { AlertDialog.Builder builder; if (Build.VERSION.SDK_INT >= 24) // Otherwise buttons on 7.0+ are nearly invisible builder = new AlertDialog.Builder(ac, R.style.AlertDialogTheme); else builder = new AlertDialog.Builder(ac); builder.setTitle(R.string.wallet_one_at_a_time); builder.setMessage(R.string.wallet_one_at_a_time_text); builder.setNeutralButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }
Example 5
Source File: EntranceActivity.java From GotoBrowser with GNU General Public License v3.0 | 6 votes |
private void showConnectorSelectionDialog() { final String[] listItems = getResources().getStringArray(R.array.connector_list); int connector_idx = -1; String connector1 = sharedPref.getString(PREF_CONNECTOR, null); for (int i = 0; i < listItems.length; i++) { if (listItems[i].equals(connector1)) { connector_idx = i; break; } } AlertDialog.Builder mBuilder = new AlertDialog.Builder(EntranceActivity.this); mBuilder.setTitle(getString(R.string.select_server)); mBuilder.setSingleChoiceItems(listItems, connector_idx, (dialogInterface, i) -> { SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(PREF_CONNECTOR, listItems[i]); editor.putString(PREF_LATEST_URL, URL_LIST[i]); editor.apply(); selectButton.setText(listItems[i]); KcUtils.showToast(getApplicationContext(), URL_LIST[i]); dialogInterface.dismiss(); }); AlertDialog mDialog = mBuilder.create(); mDialog.show(); }
Example 6
Source File: HostsActivity.java From MHViewer with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_hosts, null, false); host = view.findViewById(R.id.host); ip = view.findViewById(R.id.ip); Bundle arguments = getArguments(); if (savedInstanceState == null && arguments != null) { host.setText(arguments.getString(KEY_HOST)); ip.setText(arguments.getString(KEY_IP)); } AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setView(view); onCreateDialogBuilder(builder); AlertDialog dialog = builder.create(); dialog.setOnShowListener(d -> onCreateDialog((AlertDialog) d)); return dialog; }
Example 7
Source File: SettingsScreen.java From adamant-android with GNU General Public License v3.0 | 6 votes |
@Override public void showExitDialog() { Activity activity = getActivity(); if (activity != null) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder .setTitle(R.string.dialog_logout_title) .setMessage(R.string.dialog_logout_message) .setPositiveButton(android.R.string.yes, (dialog, which) -> { presenter.onClickExitButton(); }) .setNegativeButton(android.R.string.cancel, (dialog, which) -> { }) .show(); } }
Example 8
Source File: SettingsFragment.java From fresco with MIT License | 6 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder .setMessage(R.string.message_application_needs_restart) .setPositiveButton(android.R.string.ok, null) .setNeutralButton( R.string.message_restart_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.exit(0); } }); return builder.create(); }
Example 9
Source File: MainSettingsActivity.java From an2linuxclient with GNU General Public License v3.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogCustom); builder.setMessage(R.string.main_dialog_ask_coarse_location_access) .setPositiveButton(android.R.string.ok, (dialog, id) -> ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, UNIQUE_COARSE_LOCATION_ID)) .setNegativeButton(android.R.string.cancel, (dialog, id) -> { }); return builder.create(); }
Example 10
Source File: MainActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
private void showExitDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("提示"); builder.setMessage("确定退出CrazyDaily吗"); builder.setNegativeButton("再玩玩", null); builder.setPositiveButton("忍住泪水离开", (dialogInterface, i) -> App.getInstance().exitApp()); builder.show(); }
Example 11
Source File: RackMonthPicker.java From RackMonthPicker with Apache License 2.0 | 5 votes |
private Builder() { alertBuilder = new AlertDialog.Builder(context); contentView = LayoutInflater.from(context).inflate(R.layout.dialog_month_picker, null); contentView.setFocusable(true); contentView.setFocusableInTouchMode(true); mTitleView = (TextView) contentView.findViewById(R.id.title); mYear = (TextView) contentView.findViewById(R.id.text_year); ImageView next = (ImageView) contentView.findViewById(R.id.btn_next); next.setOnClickListener(nextButtonClick()); ImageView previous = (ImageView) contentView.findViewById(R.id.btn_previous); previous.setOnClickListener(previousButtonClick()); mPositiveButton = (Button) contentView.findViewById(R.id.btn_p); mNegativeButton = (Button) contentView.findViewById(R.id.btn_n); monthAdapter = new MonthAdapter(context, this); RecyclerView recyclerView = (RecyclerView) contentView.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new GridLayoutManager(context, 4)); recyclerView.setHasFixedSize(true); recyclerView.setAdapter(monthAdapter); Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(date); year = cal.get(Calendar.YEAR); month = cal.get(Calendar.MONTH); setColorTheme(getColorByThemeAttr(context, android.R.attr.colorPrimary, R.color.color_primary)); }
Example 12
Source File: SaveButtonDialogFragment.java From Notepad with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_save_changes) .setTitle(R.string.dialog_save_button_title) .setPositiveButton(R.string.action_save, (dialog, id) -> listener.onSaveDialogPositiveClick()) .setNegativeButton(R.string.action_discard, (dialog, id) -> listener.onSaveDialogNegativeClick()); // Create the AlertDialog object and return it return builder.create(); }
Example 13
Source File: MainActivity.java From android-speech with Apache License 2.0 | 5 votes |
private void showEnableGoogleVoiceTyping() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.enable_google_voice_typing) .setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // do nothing } }) .show(); }
Example 14
Source File: AddFriendDialog.java From Ruisi with Apache License 2.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_add_friend, null); builder.setView(view); builder.setTitle("添加好友"); content = view.findViewById(R.id.message); TextView textView = view.findViewById(R.id.user_name); textView.setText(userName); ImageView imageView = view.findViewById(R.id.logo); Picasso.get().load(userImage).placeholder(R.drawable.image_placeholder).into(imageView); view.findViewById(R.id.btn_send).setOnClickListener(view1 -> { if (checkInput()) { dialogListener.onAddFriendOkClick( content.getText().toString(), GetId.getId("uid=", userImage)); AddFriendDialog.this.getDialog().cancel(); } }); view.findViewById(R.id.btn_cancel).setOnClickListener(view12 -> dismiss()); return builder.create(); }
Example 15
Source File: ExtendedDialogFragment.java From InviZible with GNU General Public License v3.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { AlertDialog.Builder builder = assignBuilder(); if (builder != null) { return builder.create(); } else { Log.e(LOG_TAG, "ExtendedDialogFragment fault: please assignBuilder first"); return super.onCreateDialog(savedInstanceState); } }
Example 16
Source File: KeepOverscanDialogFragment.java From SecondScreen with Apache License 2.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.keep_overscan) .setTitle(R.string.quick_overscan) .setPositiveButton(R.string.action_ok, (dialog, id) -> listener.onKeepOverscanDialogPositiveClick()) .setNegativeButton(R.string.action_cancel, (dialog, id) -> listener.onKeepOverscanDialogNegativeClick()); // Create the AlertDialog object and return it return builder.create(); }
Example 17
Source File: TopicInfoFragment.java From tindroid with Apache License 2.0 | 4 votes |
private void showEditTopicText() { final Activity activity = getActivity(); if (activity == null) { return; } VxCard pub = mTopic.getPub(); final String title = pub == null ? null : pub.fn; final PrivateType priv = mTopic.getPriv(); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final View editor = View.inflate(builder.getContext(), R.layout.dialog_edit_group, null); builder.setView(editor).setTitle(R.string.edit_topic); final EditText titleEditor = editor.findViewById(R.id.editTitle); final EditText subtitleEditor = editor.findViewById(R.id.editPrivate); if (mTopic.isOwner()) { if (!TextUtils.isEmpty(title)) { titleEditor.setText(title); titleEditor.setSelection(title.length()); } } else { editor.findViewById(R.id.editTitleWrapper).setVisibility(View.GONE); } if (priv != null && !TextUtils.isEmpty(priv.getComment())) { subtitleEditor.setText(priv.getComment()); } builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newTitle = null; if (mTopic.isOwner()) { newTitle = titleEditor.getText().toString().trim(); } String newPriv = subtitleEditor.getText().toString().trim(); UiUtils.updateTitle(activity, mTopic, newTitle, newPriv, new UiUtils.TitleUpdateCallbackInterface() { @Override public void onTitleUpdated() { activity.runOnUiThread(new Runnable() { @Override public void run() { notifyContentChanged(); } }); } }); } }); builder.setNegativeButton(android.R.string.cancel, null); builder.show(); }
Example 18
Source File: CreditsDialog.java From cathode with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(@Nullable Bundle inState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) // .setTitle(R.string.credits).setAdapter(new CreditsAdapter(), null); return builder.create(); }
Example 19
Source File: PrebidServerDialog.java From prebid-mobile-android with Apache License 2.0 | 4 votes |
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { if (getActivity() != null) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.prebid_server); View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_prebid_server_selection, null, false); builder.setView(view); mServerGroup = view.findViewById(R.id.group_server); mCustomServerField = view.findViewById(R.id.field_custom_server); mServerGroup.setOnCheckedChangeListener((group, checkedId) -> { switch (checkedId) { case R.id.radio_appnexus: mCustomServerField.setVisibility(View.GONE); break; case R.id.radio_rubicon: mCustomServerField.setVisibility(View.GONE); break; case R.id.radio_custom: mCustomServerField.setVisibility(View.VISIBLE); break; } }); fillValues(); builder.setPositiveButton(R.string.action_accept, (dialog, which) -> { SettingsManager settingsManager = SettingsManager.getInstance(getActivity()); mSettingsViewModel = ViewModelProviders.of(getActivity()).get(SettingsViewModel.class); switch (mServerGroup.getCheckedRadioButtonId()) { case R.id.radio_appnexus: settingsManager.setPrebidServer(PrebidServer.APPNEXUS); settingsManager.setPrebidServerCustomUrl(""); mSettingsViewModel.setPrebidServer(PrebidServer.APPNEXUS); break; case R.id.radio_rubicon: settingsManager.setPrebidServer(PrebidServer.RUBICON); settingsManager.setPrebidServerCustomUrl(""); mSettingsViewModel.setPrebidServer(PrebidServer.RUBICON); break; case R.id.radio_custom: settingsManager.setPrebidServer(PrebidServer.CUSTOM); settingsManager.setPrebidServerCustomUrl(mCustomServerField.getText().toString()); mSettingsViewModel.setPrebidServer(PrebidServer.CUSTOM); break; } dismiss(); }); builder.setNegativeButton(R.string.action_cancel, (dialog, which) -> dismiss()); return builder.create(); } return super.onCreateDialog(savedInstanceState); }
Example 20
Source File: HostsActivity.java From EhViewer with Apache License 2.0 | 4 votes |
@Override protected void onCreateDialogBuilder(AlertDialog.Builder builder) { builder.setTitle(R.string.add_host); builder.setPositiveButton(R.string.add_host_add, null); }