Java Code Examples for com.google.android.material.dialog.MaterialAlertDialogBuilder#setPositiveButton()
The following examples show how to use
com.google.android.material.dialog.MaterialAlertDialogBuilder#setPositiveButton() .
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: AskPermission.java From CommonUtils with Apache License 2.0 | 6 votes |
public static void ask(@NonNull final FragmentActivity activity, @NonNull final String permission, @NonNull final Listener listener) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { listener.permissionGranted(permission); return; } if (ContextCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED) { listener.permissionGranted(permission); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity); listener.askRationale(builder); builder.setPositiveButton(android.R.string.ok, (dialog, which) -> request(activity, permission, listener)); DialogUtils.showDialog(activity, builder); } else { request(activity, permission, listener); } } }
Example 2
Source File: ClusterMapContributeEditActivity.java From intra42 with Apache License 2.0 | 6 votes |
public void onClickControllerDeleteRowCol(final boolean finalIsRow, final LocationWrapper wrapper) { if (wrapper == null) return; final MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(this); alert.setTitle(R.string.cluster_map_contribute_dialog_delete_title); if (finalIsRow) alert.setMessage(app.getString(R.string.cluster_map_contribute_dialog_delete_message_row, wrapper.y)); else alert.setMessage(app.getString(R.string.cluster_map_contribute_dialog_delete_message_col, wrapper.x)); alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (finalIsRow) deleteRow(wrapper.y); else deleteColumn(wrapper.x); refreshMap(); } }); alert.setNegativeButton(R.string.cancel, null); alert.show(); }
Example 3
Source File: SearchActivity.java From NClientV2 with Apache License 2.0 | 5 votes |
private void addDialog(){ MaterialAlertDialogBuilder builder=new MaterialAlertDialogBuilder(this); builder.setView(autoComplete); autoComplete.setText(""); builder.setPositiveButton(R.string.ok, (dialog, which) -> createChip()); builder.setCancelable(true).setNegativeButton(R.string.cancel,null); builder.setTitle(R.string.insert_tag_name); try{ alertDialog=builder.show(); }catch (IllegalStateException e){//the autoComplete is still attached to another View ((ViewGroup)autoComplete.getParent()).removeView(autoComplete); alertDialog=builder.show(); } }
Example 4
Source File: BoardItemListFragment.java From mimi-reader with Apache License 2.0 | 5 votes |
private void showAddBoardDialog() { if (getActivity() == null) { return; } final MaterialAlertDialogBuilder alertBuilder = new MaterialAlertDialogBuilder(getActivity()); final EditText input = new EditText(getActivity()); input.setHint(R.string.board_name_input_hint); input.setSingleLine(); input.setImeOptions(EditorInfo.IME_ACTION_DONE); alertBuilder.setView(input); alertBuilder.setPositiveButton(R.string.add, (dialog, which) -> addBoard(input.getText().toString())); alertBuilder.setNegativeButton(R.string.cancel, (dialog, which) -> Log.v(LOG_TAG, "Cancelled adding a board")); alertBuilder.setTitle(R.string.add_board); AlertDialog d = alertBuilder.create(); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); d.show(); input.setOnEditorActionListener((v, actionId, event) -> { if (actionId == EditorInfo.IME_ACTION_DONE) { addBoard(input.getText().toString()); d.dismiss(); } return true; }); }