Swift alert view with OK and Cancel: which button tapped?

If you are using iOS8, you should be using UIAlertController — UIAlertView is deprecated. Here is an example of how to use it: var refreshAlert = UIAlertController(title: “Refresh”, message: “All data will be lost.”, preferredStyle: UIAlertControllerStyle.Alert) refreshAlert.addAction(UIAlertAction(title: “Ok”, style: .Default, handler: { (action: UIAlertAction!) in print(“Handle Ok logic here”) })) refreshAlert.addAction(UIAlertAction(title: “Cancel”, style: .Cancel, handler: … Read more

How to check if activity is in foreground or in visible background?

This is what is recommended as the right solution: The right solution (credits go to Dan, CommonsWare and NeTeInStEiN) Track visibility of your application by yourself using Activity.onPause, Activity.onResume methods. Store “visibility” status in some other class. Good choices are your own implementation of the Application or a Service (there are also a few variations … Read more

How to change DatePicker dialog color for Android 5.0

The reason why Neil’s suggestion results in a fullscreen DatePicker is the choice of parent theme: <!– Theme.AppCompat.Light is not a dialog theme –> <style name=”DialogTheme” parent=”**Theme.AppCompat.Light**”> <item name=”colorAccent”>@color/blue_500</item> </style> Moreover, if you go this route, you have to specify the theme while creating the DatePickerDialog: // R.style.DialogTheme new DatePickerDialog(MainActivity.this, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() { @Override … Read more

How to disable / enable dialog negative positive buttons?

Edit for complete solution… AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(“Alert dialog title”); builder.setMessage(“This is the example code snippet to disable button if edittext attached to dialog is empty.”); builder.setPositiveButton(“PositiveButton”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // DO TASK } }); builder.setNegativeButton(“NegativeButton”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) … Read more

Is there a builtin confirmation dialog in Windows Forms?

Here is an example. You can try something like this. var confirmResult = MessageBox.Show(“Are you sure to delete this item ??”, “Confirm Delete!!”, MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { // If ‘Yes’, do something here. } else { // If ‘No’, do something here. } You can also try MessageBoxButtons.OKCancel instead of MessageBoxButtons.YesNo. It depends … Read more

Open file dialog box in JavaScript

$(“#logo”).css(‘opacity’,’0′); $(“#select_logo”).click(function(e){ e.preventDefault(); $(“#logo”).trigger(‘click’); }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <a href=”#” id=”select_logo”>Select Logo</a> <input type=”file” id=”logo”> for IE add this: $(“#logo”).css(‘filter’,’alpha(opacity = 0′);

Prompt Dialog in Windows Forms

You need to create your own Prompt dialog. You could perhaps create a class for this. public static class Prompt { public static string ShowDialog(string text, string caption) { Form prompt = new Form() { Width = 500, Height = 150, FormBorderStyle = FormBorderStyle.FixedDialog, Text = caption, StartPosition = FormStartPosition.CenterScreen }; Label textLabel = new … Read more

On showing dialog I get “Can not perform this action after onSaveInstanceState”

This is common issue. We solved this issue by overriding show() and handling exception in DialogFragment extended class public class CustomDialogFragment extends DialogFragment { @Override public void show(FragmentManager manager, String tag) { try { FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.commit(); } catch (IllegalStateException e) { Log.d(“ABSDIALOGFRAG”, “Exception”, e); } } } Note that applying … Read more

How can I get a Dialog style activity window to fill the screen?

I found the solution: In your activity which has the Theme.Dialog style set, do this: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.your_layout); getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); } It’s important that you call Window.setLayout() after you call setContentView(), otherwise it won’t work.

Choose File Dialog [closed]

You just need to override onCreateDialog in an Activity. //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + “//yourdir//”); private String mChosenFile; private static final String FTYPE = “.txt”; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, “unable to write … Read more