Prevent dialog dismissal on screen rotation in Android

The best way to avoid this problem nowadays is by using a DialogFragment. Create a new class which extends DialogFragment. Override onCreateDialog and return your old Dialog or an AlertDialog. Then you can show it with DialogFragment.show(fragmentManager, tag). Here’s an example with a Listener: public class MyDialogFragment extends DialogFragment { public interface YesNoListener { void … Read more

Looking up a deactivated widget’s ancestor is unsafe

Declare a global variable final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); then register the key on your widget build’s scaffold eg @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, … then on the dialog show(BuildContext context){ var dialog = Dialog( child: Container( margin: EdgeInsets.all(8.0), child: Form( child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ TextFormField( decoration: InputDecoration( labelText: … Read more

showDialog deprecated. What’s the alternative?

From http://developer.android.com/reference/android/app/Activity.html public final void showDialog (int id) Added in API level 1 This method was deprecated in API level 13. Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package. Simple version of showDialog(int, Bundle) that does not take any arguments. Simply calls showDialog(int, … Read more

Animate a custom Dialog

I’ve been struggling with Dialog animation today, finally got it working using styles, so here is an example. To start with, the most important thing — I probably had it working 5 different ways today but couldn’t tell because… If your devices animation settings are set to “No Animations” (Settings → Display → Animation) then … Read more

How to dismiss flutter dialog?

https://docs.flutter.io/flutter/material/showDialog.html says The dialog route created by this method is pushed to the root navigator. If the application has multiple Navigator objects, it may be necessary to call Navigator.of(context, rootNavigator: true).pop(result) to close the dialog rather just Navigator.pop(context, result). so I’d assume one of these two should do what you want.

jquery ui Dialog: cannot call methods on dialog prior to initialization

Try this instead $(document).ready(function() { $(“#divDialog”).dialog(opt).dialog(“open”); }); You can also do: var theDialog = $(“#divDialog”).dialog(opt); theDialog.dialog(“open”); That’s because the dialog is not stored in $(‘#divDialog’), but on a new div that is created on the fly and returned by the .dialog(opt) function.

Android: create a popup that has multiple selection options

You can create a String array with the options you want to show there and then pass the array to an AlertDialog.Builder with the method setItems(CharSequence[], DialogInterface.OnClickListener). An example: String[] colors = {“red”, “green”, “blue”, “black”}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(“Pick a color”); builder.setItems(colors, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) … Read more