Android simple alert dialog [duplicate]

You would simply need to do this in your onClick: AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(“Alert”); alertDialog.setMessage(“Alert message to be shown”); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, “OK”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); I don’t know from where you saw that you need DialogFragment for simply showing an alert.

How to dismiss the dialog with click on outside of the dialog?

You can use dialog.setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog. Something like, Dialog dialog = new Dialog(context) dialog.setCanceledOnTouchOutside(true); Or if your Dialog in non-model then, 1 – Set the flag-FLAG_NOT_TOUCH_MODAL for your dialog’s window attribute Window window = this.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); 2 – Add another flag to windows properties,, … Read more

Disable click outside of angular material dialog area to close the dialog (With Angular Version 4.0+)

There are two ways to do it. In the method that opens the dialog, pass in the following configuration option disableClose as the second parameter in MatDialog#open() and set it to true: export class AppComponent { constructor(private dialog: MatDialog){} openDialog() { this.dialog.open(DialogComponent, { disableClose: true }); } } Alternatively, do it in the dialog component … Read more

How to hide close button in WPF window?

WPF doesn’t have a built-in property to hide the title bar’s Close button, but you can do it with a few lines of P/Invoke. First, add these declarations to your Window class: private const int GWL_STYLE = -16; private const int WS_SYSMENU = 0x80000; [DllImport(“user32.dll”, SetLastError = true)] private static extern int GetWindowLong(IntPtr hWnd, int … Read more

How to make a edittext box in a dialog

I know its too late to answer this question but for others who are searching for some thing similar to this here is a simple code of an alertbox with an edittext AlertDialog.Builder alert = new AlertDialog.Builder(this); or new AlertDialog.Builder(mContext, R.style.MyCustomDialogTheme); if you want to change the theme of the dialog. final EditText edittext = … Read more

Handling Dialogs in WPF with MVVM

I suggest forgoing the 1990’s modal dialogs and instead implementing a control as an overlay (canvas+absolute positioning) with visibility tied to a boolean back in the VM. Closer to an ajax type control. This is very useful: <BooleanToVisibilityConverter x:Key=”booltoVis” /> as in: <my:ErrorControl Visibility=”{Binding Path=ThereWasAnError, Mode=TwoWay, Converter={StaticResource booltoVis}, UpdateSourceTrigger=PropertyChanged}”/> Here’s how I have one implemented … Read more

Receive result from DialogFragment

Use myDialogFragment.setTargetFragment(this, MY_REQUEST_CODE) from the place where you show the dialog, and then when your dialog is finished, from it you can call getTargetFragment().onActivityResult(getTargetRequestCode(), …), and implement onActivityResult() in the containing fragment. It seems like an abuse of onActivityResult(), especially as it doesn’t involve activities at all. But I’ve seen it recommended by official google … Read more