private void ShowModeConfigurationDialog(int joystickId) { // Build and display the mode configuration dialog AlertDialog modeConfigurationDialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle); builder.SetSingleChoiceItems(Resource.Array.JoystickModes, (int)GetRelatedJoystickConfiguration(joystickId).JoystickMode, delegate(object sender, DialogClickEventArgs args) { ConfigureJoystickAxis((JoystickConfiguration.JoystickModes)args.Which, joystickId); // ReSharper disable once AccessToModifiedClosure modeConfigurationDialog?.Dismiss(); }); builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogPositive, delegate { // ReSharper disable once AccessToModifiedClosure modeConfigurationDialog?.Dismiss(); }); builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogTitle); builder.SetCancelable(false); modeConfigurationDialog = builder.Create(); modeConfigurationDialog.Show(); }
public static async Task <int> ShowSingleChoiseDlg(Context context, string title, IListAdapter items, bool bAllowAbort = true) { if (context == null) { return(-1); } tcsScDlg = new TaskCompletionSource <int>(); MainThread.BeginInvokeOnMainThread(() => { try { var builder = new AlertDialog.Builder(context).SetTitle(title); if (bAllowAbort) { builder = builder.SetNegativeButton(context.Resources.GetString(context.Resources.GetIdentifier("action_abort", "string", "me.ichrono.droid")), (s, e) => { tcsScDlg.TrySetResult(-1); }); } builder = builder.SetSingleChoiceItems(items, -1, new SingleChoiceClickListener(tcsScDlg)); builder = builder.SetOnCancelListener(new myDialogCancelListener <int>(tcsScDlg)); var dlg = builder.Create(); dlg.Show(); } catch { tcsScDlg.TrySetResult(-1); } }); await tskScDlg; return(tskScDlg.Result); }
private void ShowMotorConfigurationDialog(int joystickId, int joystickAxis) { // Build and display the motor configuration dialog AlertDialog motorConfigurationDialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle); builder.SetSingleChoiceItems(GetMotorList(), GetRelatedJoystickConfiguration(joystickId).MotorIndexes[joystickAxis], delegate(object sender, DialogClickEventArgs args) { // When one motor was clicked we set it and display the next dialog SetMotorIndex(joystickId, args.Which, joystickAxis); // ReSharper disable once AccessToModifiedClosure motorConfigurationDialog?.Dismiss(); // If configured the first joystick axis we have to configure the second. // This can be done better but it works :) if (joystickAxis == 0) { ShowMotorConfigurationDialog(joystickId, ++joystickAxis); } }); builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogPositive, delegate { // ReSharper disable once AccessToModifiedClosure motorConfigurationDialog?.Dismiss(); // If configured the first joystick axis we have to configure the second. if (joystickAxis == 0) { ShowMotorConfigurationDialog(joystickId, ++joystickAxis); } }); if (joystickAxis == 0) { builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogTitle); } else if (joystickAxis == 1) { builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor2DialogTitle); } builder.SetCancelable(false); motorConfigurationDialog = builder.Create(); motorConfigurationDialog.Show(); }
public Dialog Build(AppCompatActivity activity, ActionSheetConfig config) { var dlg = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetTitle(config.Title); //.SetCustomTitle(new TextView(activity) { // Text = config.Title, // TextSize = 18.0f //}); if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null)) { var adapter = new ActionSheetListAdapter(activity, Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config); dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke()); } else { var array = config .Options .Select(x => x.Text) .ToArray(); dlg.SetSingleChoiceItems(array, config.SelectedIndex, (s, args) => { config.Options[args.Which].Action?.Invoke(); (s as AppCompatAlertDialog).Dismiss(); }); } if (config.Destructive != null) { dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke()); } if (!string.IsNullOrEmpty(config.Cancel?.Text)) { dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke()); } return(dlg.Create()); }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.action_show: AlertDialog.Builder builder = new AlertDialog.Builder(Context, Resource.Style.CustomDialogTheme); builder.SetTitle("Seleccione la opción"); builder.SetCancelable(true); string[] values = { "Solo mis órdenes", "Todas las órdenes" }; int checkedItem = 0; builder.SetSingleChoiceItems(values, checkedItem, (c, ev) => { switch (c) { case 0: Console.WriteLine("just mine"); break; case 1: Console.WriteLine("all"); break; } }); builder.SetPositiveButton("confirmar", (c, ev) => { }); builder.SetNegativeButton("cancelar", (c, ev) => { }); AlertDialog alert = builder.Create(); alert.Show(); return(true); } return(base.OnOptionsItemSelected(item)); }