public override Dialog OnCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity); string[] days = new string[7] { GetString(Resource.String.Lundi), GetString(Resource.String.Mardi), GetString(Resource.String.Mercredi), GetString(Resource.String.Jeudi), GetString(Resource.String.Vendredi), GetString(Resource.String.Samedi), GetString(Resource.String.Dimanche) }; builder.SetTitle(Resource.String.dialogTitle); builder.SetMultiChoiceItems(days, isDaychecked, (s, e) => { isDaychecked[e.Which] = e.IsChecked; }); builder.SetNeutralButton(Resource.String.valider, (sender, args) => { /* if (!Global.Instance.isInvalidPosition) * { * Global.Instance.SetDay(Global.Instance.Position,isDaychecked); * Global.Instance.Save(); * }*/ }); return(builder.Create()); }
/** * {@inheritDoc} */ override public bool PerformClick() { AlertDialog.Builder builder = new AlertDialog.Builder(Context); builder.SetMultiChoiceItems(_items, _selection, this); builder.Show(); return(true); }
public void Filter(string[] categories, int[] selected, Func <int[], int[]> callback) { var selectedBool = IntArrayToBool(selected, categories.Length); var top = Mvx.Resolve <IMvxAndroidCurrentTopActivity>(); var act = top.Activity; var adb = new AlertDialog.Builder(act, _alertDialogThemeId); adb.SetCancelable(true); adb.SetTitle(Resource.String.activity_filter_title); if (categories.Length == 0) { adb.SetMessage(Resource.String.activity_filter_empty); } else { adb.SetMultiChoiceItems(categories, selectedBool, (sender, args) => { selectedBool[args.Which] = !selectedBool[args.Which]; }); adb.SetPositiveButton("Выбрать", (sender, args) => callback(BoolArrayToInt(selectedBool, categories.Length))); } adb.SetNegativeButton("Назад", (sender, args) => { }); adb.Create().Show(); }
/// <summary> /// 多选对话框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn3_Click(object sender, EventArgs e) { AlertDialog.Builder ad_build = new AlertDialog.Builder(this); string[] array = new string[] { "语文", "数学", "英语" }; bool[] resultArray = new bool[] { false, false, false }; ad_build.SetMultiChoiceItems(array, resultArray, new EventHandler <DialogMultiChoiceClickEventArgs>((object o2, DialogMultiChoiceClickEventArgs e2) => { resultArray[e2.Which] = e2.IsChecked; MessageBoxShow("你选择的是" + array[e2.Which]); })); ad_build.SetNegativeButton("确定", new System.EventHandler <DialogClickEventArgs>((object o2, DialogClickEventArgs e2) => { StringBuilder sb = new StringBuilder(); for (int i = 0; i < resultArray.Length; i++) { if (resultArray[i]) { sb.Append(array[i]); if (i != resultArray.Length - 1) { sb.Append(","); } } } MessageBoxShow("你最终选择的有:" + sb.ToString()); })); ad_build.SetPositiveButton("取消", new System.EventHandler <DialogClickEventArgs>((object o3, DialogClickEventArgs e3) => { MessageBoxShow("已取消"); })); ad_build.SetIcon(Android.Resource.Drawable.StatSysWarning); ad_build.Show(); }
public override bool PerformClick() { var builder = new AlertDialog.Builder(context); builder.SetMultiChoiceItems(items, selection, this); builder.Show(); return(true); }
//This is deprecated in API level 8 //protected override Dialog OnCreateDialog(int id) //This is deprecated in API level 13 protected override Dialog OnCreateDialog(int id, Bundle args) { switch (id) { case AlertDialog: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.bomb_dialog_title); builder.SetPositiveButton(Resource.String.dialog_signal, (s, e) => { /*Do something here!*/ }); builder.SetNegativeButton(Resource.String.dialog_main_screen, (s, e) => { }); return(builder.Create()); } case ListDialog: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.list_dialog_title); builder.SetSingleChoiceItems(Resource.Array.list_dialog_items, 0, ListClicked); builder.SetPositiveButton(Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.dialog_cancel, CancelClicked); return(builder.Create()); } case MultiChoiceDialog: { var builder = new AlertDialog.Builder(this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIcon(Resource.Drawable.Icon); builder.SetTitle(Resource.String.multi_choice_dialog_title); builder.SetMultiChoiceItems(Resource.Array.multilist_dialog_items, new[] { false, true, false, true }, MultiListClicked); builder.SetPositiveButton(Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.multi_dialog_cancel, CancelClicked); return(builder.Create()); } case CustomViewDialog: { var customView = LayoutInflater.Inflate(Resource.Layout.CustomDialog, null); var builder = new AlertDialog.Builder(this); builder.SetView(customView); builder.SetPositiveButton(Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.dialog_cancel, CancelClicked); return(builder.Create()); } } return(base.OnCreateDialog(id, args)); }
private void SpecialClicked(Button b, WeaponItem atk, bool ranged) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(this); builderSingle.SetTitle("Special"); List <String> options = new List <string>(); List <WeaponSpecialAbility> specialList = ranged?WeaponSpecialAbility.RangedAbilities:WeaponSpecialAbility.MeleeAbilities; bool [] itemschecked = new bool[specialList.Count]; int i = 0; foreach (WeaponSpecialAbility ab in specialList) { options.Add(ab.Name); if (atk.SpecialAbilities != null && atk.SpecialAbilities.Contains(ab.Name)) { itemschecked[i] = true; } i++; } builderSingle.SetMultiChoiceItems(options.ToArray(), itemschecked, (sender, args) => { int index = args.Which; string special = options[index]; SortedDictionary <string, string> dict = new SortedDictionary <string, string>(atk.SpecialAbilitySet); if (args.IsChecked) { dict[special] = special; } else { dict.Remove(special); } atk.SpecialAbilitySet = dict; }); builderSingle.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => { if (ranged) { BuildRanged(); } else { BuildMeleeGroup(); } }; builderSingle.SetOnCancelListener(new SpecialListener(this, ranged)); builderSingle.Show(); }
private void showDeletePreferencesPopup() { var settings = new Settings(this); var connections = settings.GetConnections(); string[] items = connections.Select(p => p.Server + ":" + p.Port).ToArray(); List <int> selected = new List <int>(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Supprimer des connexions"); builder.SetPositiveButton("Annuler", delegate(object sender, DialogClickEventArgs e) { this.returnToLoginScreen(); }); builder.SetNegativeButton("Supprimer la selection", delegate(object sender, DialogClickEventArgs e) { if (selected.Count > 0) { foreach (var index in selected.OrderByDescending(p => p)) { connections.RemoveAt(index); } selected.Clear(); settings.SaveConnections(connections); } this.returnToLoginScreen(); }); var itemsSelected = new bool[items.Length]; for (int i = 0; i < itemsSelected.Length; i++) { itemsSelected[0] = false; } builder.SetMultiChoiceItems(items, itemsSelected, delegate(object sender, DialogMultiChoiceClickEventArgs e) { var index = (int)e.Which; if (e.IsChecked && !selected.Contains(index)) { selected.Add(index); } else if (!e.IsChecked && selected.Contains(index)) { selected.Remove(index); } }); var alert = builder.Create(); alert.Show(); }
private void App_Click(AppClickedEventArgs e) { var textView = e.View; currentSelectedAppPackage = textView.GetTag(Resource.String.defaulttag).ToString(); using (AlertDialog.Builder builder = new AlertDialog.Builder(textView.Context)) { builder.SetTitle(textView.Text); builder.SetMultiChoiceItems(new string[] { textView.Context.GetString(Resource.String.blacklisted), textView.Context.GetString(Resource.String.partiallyblocked), textView.Context.GetString(Resource.String.nonallowedtoturnonscreen) }, GetLevelOfBlocking(currentSelectedAppPackage), DialogMultichoiceClick); builder.SetPositiveButton("Ok", OnDialogPositiveButtonEventArgs); builder.Create(); builder.Show(); } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var builder = new AlertDialog.Builder(Context); if (ViewModel.IsSingleChoice) { var selectedItem = ViewModel.Options.FirstOrDefault(item => item.IsSelected); builder.SetSingleChoiceItems(ViewModel.Options.Select(o => o.ToString()).ToArray(), ViewModel.Options.IndexOf(selectedItem), ItemSelected); } else { builder.SetMultiChoiceItems(ViewModel.Options.Select(o => o.ToString()).ToArray(), ViewModel.Options.Select(o => o.IsSelected).ToArray(), (EventHandler <DialogMultiChoiceClickEventArgs>)null); } return(builder.Create()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.CriarEventoView); alert = new Android.App.AlertDialog.Builder(this); bool[] checkedItems = new bool[100]; alert.SetMultiChoiceItems(DataService.itensDeficiencias, checkedItems, (sender, e) => { int index = e.Which; checkedItems[index] = e.IsChecked; }); alert.SetPositiveButton("Ok", (sender, e) => { string aux = ""; for (int i = 0; i < 4; i++) { if (checkedItems[i] == true) { aux += "1"; } else { aux += "0"; } } CriarEventoViewModel.DeficienciasEvento = aux; }); Button button = FindViewById <Button> (Resource.Id.ButtonDefi); //Assign The Event To Button button.Click += delegate { Dialog dialog = alert.Create(); dialog.Show(); }; }
private void ConfigureBuilder(AlertDialog.Builder builder, DialogServiceMultiItemsBundle bundle, TaskCompletionSource <List <int> > tcs) { var checkedItemsIndex = GetIndexOfCheckedItems(bundle); var orgCheckedItemsIndex = new List <int>(checkedItemsIndex); builder.SetTitle(bundle.Title); var titles = bundle.Items.Select(x => x.Title).ToArray(); builder.SetMultiChoiceItems(titles, bundle.CheckedItems, (sender, e) => { if (e.IsChecked) { checkedItemsIndex.Add(e.Which); } else if (checkedItemsIndex.Contains(e.Which)) { checkedItemsIndex.Remove(e.Which); } }); builder.SetPositiveButton(bundle.PositiveLabel, (sender, e) => { if (tcs.TrySetResult(checkedItemsIndex) == false) { Console.WriteLine("Unable to set CHECKED_ITEMS result in builder"); } }); builder.SetNegativeButton(bundle.NegativeLabel, (sender, e) => { if (tcs.TrySetResult(orgCheckedItemsIndex) == false) { Console.WriteLine("Unable to set ORG_CHECKED_ITEMS result in builder"); } }); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBeanMr1) { builder.SetOnDismissListener(new MyDismissListener(tcs, orgCheckedItemsIndex)); } }
private void ShowFilterDialog() { var builder = new AlertDialog.Builder(this); builder.SetMultiChoiceItems(filters, new bool[filters.Length], (sender, args) => { switch (args.Which) { case 0: ViewModel.ViewActionViewModel.IsClearedFilterActive = args.IsChecked; break; case 1: ViewModel.ViewActionViewModel.IsRecurringFilterActive = args.IsChecked; break; } }); builder.SetTitle(Strings.SelectFilterTitle); builder.SetPositiveButton(Strings.DoneLabel, (sender, args) => { }); var dialog = builder.Create(); dialog.Show(); }
public override bool PerformClick() { if (_items != null) { AlertDialog.Builder builder = new AlertDialog.Builder(contexT); builder.SetMultiChoiceItems(_items, mSelection, this); _itemsAtStart = getSelectedItemsAsString(); builder.SetPositiveButton("Submit", (senderAlert, args) => { Array.Copy(mSelection, 0, mSelectionAtStart, 0, mSelection.Length); sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); builder.Dispose(); }); builder.SetNegativeButton("Cancel", (senderAlert, args) => { simple_adapter.Clear(); simple_adapter.Add(_itemsAtStart); Array.Copy(mSelectionAtStart, 0, mSelection, 0, mSelectionAtStart.Length); builder.Dispose(); }); builder.Show(); } else { Toast.MakeText(contexT, "There are no items to show, add you can add an item by pressing the '+' button", ToastLength.Short).Show(); } return(true); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.driver_info_box, container, false); #region Иннициализация переменных BoxTextIdValue = view.FindViewById <TextView>(Resource.Id.BoxTextIdValue); BoxTexWeight = view.FindViewById <TextView>(Resource.Id.BoxTexWeight); BoxTextTemperature = view.FindViewById <TextView>(Resource.Id.BoxTextTemperature); BoxTexBattery = view.FindViewById <TextView>(Resource.Id.BoxTexBattery); BoxTextIllumination = view.FindViewById <TextView>(Resource.Id.BoxTextIllumination); BoxTextHumidity = view.FindViewById <TextView>(Resource.Id.BoxTextHumidity); BoxTextGate = view.FindViewById <TextView>(Resource.Id.BoxTextGate); BoxTextFold = view.FindViewById <TextView>(Resource.Id.BoxTextFold); //BoxTextLock = view.FindViewById<TextView>(Resource.Id.BoxTextLock); BoxTextEvents = view.FindViewById <TextView>(Resource.Id.BoxTextEvents); BoxButtonStop = view.FindViewById <Button>(Resource.Id.BoxButtonStop); BoxButtonDetach = view.FindViewById <Button>(Resource.Id.BoxButtonDetach); BoxButtonVideo = view.FindViewById <Button>(Resource.Id.BoxButtonVideo); BoxButtonPhoto = view.FindViewById <Button>(Resource.Id.BoxButtonPhoto); btn_fold = view.FindViewById <Button>(Resource.Id.btn_fold); btn_gate = view.FindViewById <Button>(Resource.Id.btn_gate); BoxButtonStop.Enabled = (StaticBox.isDepot) ? false : true; btn_gate.Enabled = (StaticBox.isDepot) ? false : true; btn_fold.Enabled = (StaticBox.isDepot) ? false : true; BoxLinearAlarms = view.FindViewById <LinearLayout>(Resource.Id.BoxLinearAlarms); BoxButtonDetach.Text = (StaticBox.isDepot) ? "Прикрепить" : "Открепить"; btn_fold.Enabled = (StaticBox.isDepot) ? false : true; #endregion swipe = view.FindViewById <SwipeRefreshLayout>(Resource.Id.SwipeRefreshDriver); swipe.SetColorSchemeColors(Color.Red, Color.Green, Color.Blue, Color.Yellow); swipe.Refresh += RefreshLayout_Refresh; BoxTextEvents.Click += BoxTextEvents_Click; GetBoxParameters(); if (StaticBox.alarms != null) { foreach (var alarm in StaticBox.alarms) { // Add textview 1 var textview = new TextView(Activity) { LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent), Text = alarm.name + "\n" + alarm.raised_at.ToString(), TextSize = 11, Gravity = GravityFlags.Center }; textview.SetBackgroundResource(Resource.Drawable.button_cancel); textview.SetTextColor(Color.White); BoxLinearAlarms.AddView(textview); } } btn_gate.Click += delegate { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); if (btn_gate.Text == "Поднять") { alert.SetTitle("Поднять роллету"); alert.SetMessage("Вы действительно хотите поднять роллету?"); alert.SetPositiveButton("Да", (senderAlert, args) => { MakeUnlockRollete(alert); }); alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); } else { alert.SetTitle("Опустить роллету"); alert.SetMessage("Вы действительно хотите опустить роллету?"); alert.SetPositiveButton("Да", (senderAlert, args) => { MakeLockRollete(alert); }); } alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }; btn_fold.Click += delegate { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); if (btn_fold.Text == "Сложить") { alert.SetTitle("Сложить контейнер"); alert.SetMessage("Вы действительно хотите сложить контейнер?"); alert.SetPositiveButton("Сложить", (senderAlert, args) => { MakeFold(alert); }); alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); } else if (btn_fold.Text == "Разложить") { alert.SetTitle("Разложить контейнер"); alert.SetMessage("Вы действительно хотите разложить контейнер?"); alert.SetPositiveButton("Разложить", (senderAlert, args) => { MakeUnfold(alert); }); } alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }; BoxButtonDetach.Click += delegate { if (StaticBox.isDepot) { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Прикрепить контейнер"); alert.SetMessage("Вы действительно прикрепить контейнер?"); alert.SetPositiveButton("Продолжить", (senderAlert, args) => { Attach(alert); }); alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Вы действительно хотите открепить контейнер?"); //alert.SetMessage("Вы действительно открепить контейнер?"); List <string> Item = new List <string>(); Item.Add("Создать задачу забрать контейнер для другого водителя."); bool[] toDownload = { false }; alert.SetMultiChoiceItems(Item.ToArray(), toDownload, (sender, e) => { int index = e.Which; toDownload[index] = e.IsChecked; }); alert.SetPositiveButton("Продолжить", (senderAlert, args) => { Dettach(alert, toDownload[0]); }); alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } }; BoxButtonStop.Click += delegate { AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Подтверждение"); alert.SetMessage("Вы действительно хотите остановить выполнение команд?"); alert.SetPositiveButton("Да", (senderAlert, args) => { StopCommands(); }); alert.SetNegativeButton("Отмена", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }; BoxButtonPhoto.Click += delegate { AlertDialogCreation("Сделать фотографию", "Вы действительно хотите сделать фотографию с камеры контейнера?"); }; BoxButtonVideo.Click += delegate { AlertDialogCreation("Сделать видео", "Вы действительно хотите сделать видео с камеры контейнера?"); }; return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); textView1 = FindViewById <TextView>(Resource.Id.textView1); btnDisplay = FindViewById <Button>(Resource.Id.btnDisplay); btnDisplay.Click += delegate { // clear textview textView1.Text = ""; // iterate through selectedCurrencyList and display in the textview foreach (var item in selectedCurrencyList) { textView1.Text += item + "\n"; } }; button = FindViewById <Button>(Resource.Id.button1); button.Click += delegate { // clear user's selection to begin selectedCurrencyList.Clear(); // list of items for user to select from string[] items = { "EUR", "GBP", "CAD", "USD", "YUAN", "FRC", "LYP", "VIX" }; // bool array for selected checkboxes in MultiItemSelect bool[] selected = new bool[items.Length]; using (var dialog = new AlertDialog.Builder(this)){ dialog.SetTitle("Alert Title"); dialog.SetPositiveButton("Close", delegate { }); // Sets whether this dialog is cancelable with the Android.Views.KeyEvent.KEYCODE_BACK key. //dialog.SetCancelable(true); // check all boxes and add all items to list(s) dialog.SetNeutralButton("ALL", delegate { // clear list 1st to avoid getting duplicate entries selectedCurrencyList.Clear(); // set all items in bool[] selected to TRUE for (int i = 0; i < selected.Length; i++) { selected[i] = true; selectedCurrencyList.Add(items[i]); } }); // deselect all boxes & clear list dialog.SetNegativeButton("Clear", delegate { selectedCurrencyList.Clear(); }); //// Set.Items() method (Displays checkboxes) //dialog.SetItems(items, (s, e) => //{ // int index = e.Which; //}); //// Adapter method (Doesn't display checkboxes!!) //var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, items); //dialog.SetAdapter(adapter, (s, e) => //{ // var index = e.Which; //}); //// Single select Radio Button //int selected = -1; //dialog.SetSingleChoiceItems(items, selected, (s, e) => //{ // selected = e.Which; // Toast.MakeText(this, "You selected: " + items[selected], ToastLength.Short).Show(); //}); //// Multi-Select Checklist - Original //bool[] selected = new bool[items.Length]; //dialog.SetMultiChoiceItems(items, selected, // (s, e) => { // int index = e.Which; // bool isChecked = e.IsChecked; // selected[index] = isChecked; // Toast.MakeText(this, "You selected: " + items[index], ToastLength.Short).Show(); // selectedCurrencyList.Add(items[index]); //}); // Multi-Select Checklist - EXperiments //bool[] selected = new bool[items.Length]; //// set all items in bool[] to FALSE //for (int i = 0; i < selected.Length; i++) //{ // selected[i] = false; // selectedCurrencyList.Remove(items[i]); //} dialog.SetMultiChoiceItems(items, selected, (s, e) => { int index = e.Which; bool isChecked = e.IsChecked; selected[index] = isChecked; Toast.MakeText(this, "You clicked: " + items[index] + "\nChecked: " + e.IsChecked, ToastLength.Short).Show(); // add item to list if now selected - ie isChecked is now TRUE if (isChecked) { selectedCurrencyList.Add(items[index]); } else { selectedCurrencyList.Remove(items[index]); } }); dialog.Show(); }// end Using };// end delegate }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); base.OnCreateView(inflater, container, savedInstanceState); View rootView = inflater.Inflate(Resource.Layout.Block1Fragment, container, false); pharmacyID = Arguments.GetInt(Common.PHARMACY_ID); user = Common.GetCurrentUser(); netCategories = Common.GetNetCategories(user.username); promos = Common.GetPromos(user.username); merchant = Common.GetMerchant(user.username); territory = Common.GetTerritory(user.username); pharmacy = PharmacyManager.GetPharmacy(pharmacyID); var tradenets = Common.GetTradeNets(user.username); Dictionary <int, string> tnDict = new Dictionary <int, string> (); foreach (var item in tradenets) { tnDict.Add(item.id, item.shortName); } ; attendance = AttendanceManager.GetCurrentAttendance(); if (attendance == null) { attendance = AttendanceManager.GetLastAttendance(pharmacyID); if (attendance == null) { attendance = new Attendance() { pharmacy = pharmacyID, date = DateTime.Now, merchant = merchant.id }; } else { attendance.id = -1; attendance.date = DateTime.Now; } } rootView.FindViewById <TextView> (Resource.Id.b1fTradenetText).Text = tnDict [pharmacy.tradenet]; //@"Аптечная Сеть"; rootView.FindViewById <TextView> (Resource.Id.b1fCityText).Text = territory.baseCity; rootView.FindViewById <TextView> (Resource.Id.b1fPharmacyNameText).Text = pharmacy.shortName; rootView.FindViewById <TextView> (Resource.Id.b1fPharmacyAddressText).Text = pharmacy.address; rootView.FindViewById <TextView> (Resource.Id.b1fCategoryInOTCText).Text = pharmacy.category_otc; rootView.FindViewById <TextView> (Resource.Id.b1fLastAttendanceText).Text = pharmacy.prev == DateTime.MinValue ? String.Empty : pharmacy.prev.ToString(@"d"); rootView.FindViewById <TextView> (Resource.Id.b1fNextAttendanceText).Text = pharmacy.next == DateTime.MinValue ? String.Empty : pharmacy.next.ToString(@"d"); rootView.FindViewById <TextView> (Resource.Id.b1fAllAttendanciesText).Text = AttendanceManager.GetStatistics(pharmacy.id); categoryNetSpinner = rootView.FindViewById <Spinner> (Resource.Id.b1fCategoryNetSpinner); ArrayAdapter adapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleSpinnerItem, (from item in netCategories select item.key).ToArray <string>()); adapter.SetDropDownViewResource(Resource.Layout.SpinnerItem); categoryNetSpinner.Adapter = adapter; categoryNetSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => { attendance.category_net = netCategories[e.Position].id; }; // SetValue for (int i = 0; i < netCategories.Count; i++) { if (netCategories [i].id == attendance.category_net) { categoryNetSpinner.SetSelection(i); } } telephoneEdit = rootView.FindViewById <EditText> (Resource.Id.b1fTelephoneEdit); telephoneEdit.Text = attendance.telephone; purchaserFIOEdit = rootView.FindViewById <EditText> (Resource.Id.b1fPurchaserFIOEdit); purchaserFIOEdit.Text = attendance.purchaserFIO; promosEdit = rootView.FindViewById <EditText> (Resource.Id.b1fPromosEdit); promosButton = rootView.FindViewById <Button> (Resource.Id.b1fPromosButton); promosButton.Click += (object sender, EventArgs e) => { bool[] checkedItems = new bool[promos.Count]; if (attendance.promos != null) { for (int i = 0; i < promos.Count; i++) { if (attendance.promos.Contains(promos[i].id)) { checkedItems[i] = true; tempPromos.Add(promos[i].id); } } } string[] items = (from promo in promos orderby promo.id select promo.name).ToArray <string>(); AlertDialog.Builder builder; builder = new AlertDialog.Builder(Activity); builder.SetTitle("Выбор ПРОМО-матералов"); builder.SetCancelable(false); builder.SetMultiChoiceItems(items, checkedItems, MultiListClicked); builder.SetPositiveButton(@"Сохранить", delegate { attendance.promos = tempPromos.ToArray <int>(); builder.Dispose(); RefreshPromos(); } ); builder.SetNegativeButton(@"Отмена", delegate { builder.Dispose(); }); builder.Show(); }; RefreshPromos(); pharmacistCountEdit = rootView.FindViewById <EditText> (Resource.Id.b1fPharmacistCountEdit); pharmacistCountEdit.Text = attendance.pharmacistCount.ToString(); commentEdit = rootView.FindViewById <EditText> (Resource.Id.b1fCommentEdit); commentEdit.Text = attendance.comment; RefreshControlsState(); return(rootView); }
protected override Dialog OnCreateDialog(int id) { switch (id) { case DIALOG_YES_NO_MESSAGE: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: { var builder = new AlertDialog.Builder(this, Android.App.AlertDialog.ThemeTraditional); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: { var builder = new AlertDialog.Builder(this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } case DIALOG_YES_NO_LONG_MESSAGE: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage(Resource.String.alert_dialog_two_buttons_msg); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton(Resource.String.alert_dialog_something, NeutralClicked); return(builder.Create()); } case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage(Resource.String.alert_dialog_two_buttons2ultra_msg); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton(Resource.String.alert_dialog_something, NeutralClicked); return(builder.Create()); } case DIALOG_LIST: { var builder = new AlertDialog.Builder(this); builder.SetTitle(Resource.String.select_dialog); builder.SetItems(Resource.Array.select_dialog_items, ListClicked); return(builder.Create()); } case DIALOG_PROGRESS: { progress_dialog = new ProgressDialog(this); progress_dialog.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); progress_dialog.SetTitle(Resource.String.select_dialog); progress_dialog.SetProgressStyle(ProgressDialogStyle.Horizontal); progress_dialog.Max = MAX_PROGRESS; progress_dialog.SetButton(-1, GetText(Resource.String.alert_dialog_ok), OkClicked); progress_dialog.SetButton(-2, GetText(Resource.String.alert_dialog_cancel), CancelClicked); return(progress_dialog); } case DIALOG_SINGLE_CHOICE: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_single_choice); builder.SetSingleChoiceItems(Resource.Array.select_dialog_items2, 0, ListClicked); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } case DIALOG_MULTIPLE_CHOICE: { var builder = new AlertDialog.Builder(this); builder.SetIcon(Resource.Drawable.ic_popup_reminder); builder.SetTitle(Resource.String.alert_dialog_multi_choice); builder.SetMultiChoiceItems(Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } case DIALOG_MULTIPLE_CHOICE_CURSOR: { var projection = new string[] { ContactsContract.Contacts.InterfaceConsts.Id, ContactsContract.Contacts.InterfaceConsts.DisplayName, ContactsContract.Contacts.InterfaceConsts.SendToVoicemail }; var cursor = ManagedQuery(ContactsContract.Contacts.ContentUri, projection, null, null, null); var builder = new AlertDialog.Builder(this); builder.SetIcon(Resource.Drawable.ic_popup_reminder); builder.SetTitle(Resource.String.alert_dialog_multi_choice_cursor); builder.SetMultiChoiceItems(cursor, ContactsContract.Contacts.InterfaceConsts.SendToVoicemail, ContactsContract.Contacts.InterfaceConsts.DisplayName, MultiListClicked); return(builder.Create()); } case DIALOG_TEXT_ENTRY: { // This example shows how to add a custom layout to an AlertDialog var factory = LayoutInflater.From(this); var text_entry_view = factory.Inflate(Resource.Layout.alert_dialog_text_entry, null); var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.alert_dialog_text_entry); builder.SetView(text_entry_view); builder.SetPositiveButton(Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.alert_dialog_cancel, CancelClicked); return(builder.Create()); } } return(null); }
private void Initialize() { // Create your application here signUpButton = FindViewById <Button>(Resource.Id.manage_profile_loginbutton); cancelButton = FindViewById <Button>(Resource.Id.manage_profile_cancelbutton); vehiclebodytype = FindViewById <EditText>(Resource.Id.manage_profile_vehicle_body_type); courierMobileNumber = FindViewById <EditText>(Resource.Id.manage_profile_courier_mobile_number); displayName = FindViewById <EditText>(Resource.Id.manage_profile_etdisplay_name); profilePicture = FindViewById <ImageView>(Resource.Id.manage_profile); pricePerKM = FindViewById <EditText>(Resource.Id.manage_profile_etPricePerKM); message = FindViewById <TextView>(Resource.Id.manage_profile_tvmessage); //Set Date bool[] checkedItems = new bool[9]; if (ViewModel.User.Courier.VehicleBodyTypes != null) { foreach (var item in ViewModel.User.Courier.VehicleBodyTypes) { int position = Array.IndexOf(items, item); if (position != -1) { checkedItems[position] = true; if (vehiclebodytype.Text.Length > 30) { vehiclebodytype.Text = vehiclebodytype.Text.Substring(0, 31); vehiclebodytype.Text = vehiclebodytype.Text + "..."; } else { if (string.IsNullOrWhiteSpace(vehiclebodytype.Text)) { vehiclebodytype.Text = item; } else { vehiclebodytype.Text = vehiclebodytype.Text + ", " + item; } } } } } User = new User(); User = ViewModel.User; Context mContext = Android.App.Application.Context; ImageManager imageManager = new ImageManager(mContext); courierMobileNumber.Text = ViewModel.User.Courier.MobileNumber; displayName.Text = ViewModel.User.DisplayName; pricePerKM.Text = ViewModel.User.Courier.PricePerKM.ToString(); if (ViewModel.User.ProfilePicture == null) { profilePicture.SetImageResource(Resource.Drawable.profile_generic); } else { profilePicture.SetImageBitmap(imageManager.ConvertStringToBitMap(ViewModel.User.ProfilePicture)); } // set OnCheckedChanged vehiclebodytype.Touch += OnVehiclebodytype_TextChanged; var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.choosevehiclebodytypes, Android.Resource.Layout.SimpleSpinnerDropDownItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); profilePicture.Click += SelectProfilePicture_Click; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Choose Your Vehicles Body Type"); builder.SetMultiChoiceItems(Resource.Array.vehiclebodytypeSignUp_array, checkedItems, delegate { }); builder.SetPositiveButton("OK", delegate { var sads = vehiclebodytypeDialog.ListView.CheckedItemPositions; List <string> selectedItems = new List <string>(); vehiclebodytype.Text = ""; for (int i = 0; i < items.Length; i++) { var isChecked = sads.Get(i); if (isChecked) { var fd = items.ElementAt(i); selectedItems.Add(fd); if (vehiclebodytype.Text.Length > 30) { vehiclebodytype.Text = vehiclebodytype.Text.Substring(0, 31); vehiclebodytype.Text = vehiclebodytype.Text + "..."; } else { if (string.IsNullOrWhiteSpace(vehiclebodytype.Text)) { vehiclebodytype.Text = fd; } else { vehiclebodytype.Text = vehiclebodytype.Text + ", " + fd; } } } } mSelectedItems = selectedItems; vehiclebodytypeDialog.Cancel(); }); vehiclebodytypeDialog = builder.Create(); signUpButton.Click += SignUpButton_Click; cancelButton.Click += CancelButton_Click; }
public static void ShowMultiSelectListString(Context context, string message, string[] items, List <string> userSelectedItemsNames, Action <List <string> > actionOnSelect) { var selectedItems = GetIsSelectedList(items, userSelectedItemsNames).ToArray(); var selectAll = true; //do zanzaczania wszystkich var itemsList = items.ToList(); itemsList.Insert(0, "Wszystko"); items = itemsList.ToArray(); var alertDialog = default(AlertDialog); AlertDialog.Builder buider = new AlertDialog.Builder(context); buider.SetTitle(message); buider.SetMultiChoiceItems(items, selectedItems, (sender, args) => { bool isChecked = alertDialog.ListView.IsItemChecked(args.Which); if (args.Which == 0) { if (selectAll) { for (int i = 1; i < alertDialog.ListView.Adapter.Count; i++) { // we start with first element after "Select all" choice if (isChecked && !alertDialog.ListView.IsItemChecked(i) || !isChecked && alertDialog.ListView.IsItemChecked(i)) { alertDialog.ListView.PerformItemClick(alertDialog.ListView, i, 0); } } } } else { if (!isChecked && alertDialog.ListView.IsItemChecked(0)) { // if other item is unselected while "Select all" is selected, unselect "Select all" // false, performItemClick, true is a must in order for this code to work selectAll = false; alertDialog.ListView.PerformItemClick(alertDialog.ListView, 0, 0); selectAll = true; } } }); buider.SetPositiveButton("Ok", (sender, args) => { userSelectedItemsNames.Clear(); for (int i = 1; i < alertDialog.ListView.Adapter.Count; i++) { if (alertDialog.ListView.IsItemChecked(i)) { userSelectedItemsNames.Add(items[i]); } } actionOnSelect(userSelectedItemsNames); alertDialog.Dismiss(); }); buider.SetNegativeButton("Anuluj", (sender, args) => { alertDialog.Dismiss(); }); alertDialog = buider.Create(); alertDialog.Show(); }
private void Initialize() { // Create your application here signUpButton = FindViewById <Button>(Resource.Id.button_sign_up); vehiclebodytype = FindViewById <EditText>(Resource.Id.signup_vehicle_body_type); username = FindViewById <EditText>(Resource.Id.signup_etUsername); courierMobileNumber = FindViewById <EditText>(Resource.Id.signup_courier_mobile_number); displayName = FindViewById <EditText>(Resource.Id.signup_etdisplay_name); confirmPassword = FindViewById <EditText>(Resource.Id.signup_confirm_password); password = FindViewById <EditText>(Resource.Id.signup_password); profilePicture = FindViewById <ImageView>(Resource.Id.signup_profile_picture); courierCharges = FindViewById <TextView>(Resource.Id.signup_tvCourierCharges); pricePerKM = FindViewById <EditText>(Resource.Id.signup_etPricePerKM); message = FindViewById <TextView>(Resource.Id.signup_tvmessage); ViewModel = new SignUpViewModel(); // set OnCheckedChanged vehiclebodytype.Touch += OnVehiclebodytype_TextChanged; var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.choosevehiclebodytypes, Android.Resource.Layout.SimpleSpinnerDropDownItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); profilePicture.Click += SelectProfilePicture_Click; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Choose Your Vehicles Body Type"); builder.SetMultiChoiceItems(Resource.Array.vehiclebodytypeSignUp_array, null, delegate { }); builder.SetPositiveButton("OK", delegate { var sads = vehiclebodytypeDialog.ListView.CheckedItemPositions; List <string> selectedItems = new List <string>(); vehiclebodytype.Text = ""; for (int i = 0; i < items.Length; i++) { var isChecked = sads.Get(i); if (isChecked) { var fd = items.ElementAt(i); selectedItems.Add(fd); if (vehiclebodytype.Text.Length > 30) { vehiclebodytype.Text = vehiclebodytype.Text.Substring(0, 31); vehiclebodytype.Text = vehiclebodytype.Text + "..."; } else { if (string.IsNullOrWhiteSpace(vehiclebodytype.Text)) { vehiclebodytype.Text = fd; } else { vehiclebodytype.Text = vehiclebodytype.Text + ", " + fd; } } } } mSelectedItems = selectedItems; vehiclebodytypeDialog.Cancel(); }); vehiclebodytypeDialog = builder.Create(); signUpButton.Click += SignUpButton_Click; }