private void ChangeStorage(StorageItemQuantityResult storageItem, StorageItemQuantityListViewAdapter adapter) { var storages = Database.GetStorageNames(); if (storages.Count == 0) { return; } storages.Insert(0, "[Kein Lagerort]"); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.SetTitle("Lagerort auswählen"); dialog.SetItems(storages.ToArray(), (sender, args) => { if (args.Which == 0) { storageItem.StorageName = null; } else { storageItem.StorageName = storages[args.Which]; } storageItem.IsChanged = true; adapter.NotifyDataSetChanged(); return; }); dialog.Show(); }
private async Task <int> GetTreeHealthValue() { // Create UI for tree health selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("How healthy is this tree?"); builder.SetItems(new string[] { "Dead", "Distressed", "Healthy" }, Choose_Click); builder.SetOnCancelListener(this); builder.Show(); // Get the selected terminal. _healthCompletionSource = new TaskCompletionSource <int>(); int selectedIndex = await _healthCompletionSource.Task; // Return a tree health value based on the users selection. switch (selectedIndex) { case 0: // Dead tree. return(0); case 1: // Distressed tree. return(5); case 2: // Healthy tree. return(10); default: return(0); } }
void OnClick() { Picker model = Element; if (_dialog == null) { using (var builder = new AlertDialog.Builder(Context)) { builder.SetTitle(model.Title ?? ""); string[] items = model.Items.ToArray(); builder.SetItems(items, (s, e) => ((IElementController)model).SetValueFromRenderer(Picker.SelectedIndexProperty, e.Which)); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { }); ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.DismissEvent += (sender, args) => { (Element as IElementController)?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); _dialog.Dispose(); _dialog = null; }; _dialog.Show(); } }
private void ListAdapter_ItemClicked(object sender, StorageItemEventArgs e) { var adapter = sender as StorageItemQuantityListViewAdapter; string[] actions = { "Anzahl", "Ablaufdatum", "Lagerort" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Angaben ändern"); builder.SetItems(actions, (sender2, args) => { switch (args.Which) { case 0: // Anzahl this.ChangeQuantity(e.StorageItem, adapter); break; case 1: // Datum this.ChangeBestBeforeDate(e.StorageItem, adapter); break; case 2: // Lagerort this.ChangeStorage(e.StorageItem, adapter); break; } return; }); builder.Show(); }
private void ShowSubscribedDialog() { if (DownloadManager.IsLogged()) { var dialog = new AlertDialog.Builder(Activity); dialog.SetTitle(String.Format(GetString(Resource.String.iap_subscribeTo), Activity.ApplicationInfo.LoadLabel(Activity.PackageManager))); string[] items = (from a in _Abbonamenti where a.Prezzo != "" select a.Nome + " " + a.Prezzo).ToArray(); dialog.SetItems(items, SubscribedDialogClicked); dialog.SetNegativeButton(GetString(Resource.String.gen_cancel), delegate { return; }); dialog.Create(); dialog.Show().SetDivider(); } else { Action action = delegate { ShowSubscribedDialog(); }; ActivitiesBringe.SetObject("loginSuccess", action); var logActivity = new Intent(Activity, typeof(LoginActivity)); StartActivity(logActivity); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreate(savedInstanceState); data = new string[] { "Mathematics Physics", "Biologya Chemistric", "Physics Chemistric" }; View view = inflater.Inflate(Resource.Layout.choose_subjects_frag, container, false); Subject4 = (TextView)view.FindViewById(Resource.Id.textView4); Subject5 = (TextView)view.FindViewById(Resource.Id.textView5); ImageView Images = (ImageView)view.FindViewById(Resource.Id.imageView1); Button button = (Button)view.FindViewById(Resource.Id.button1); SelectSubject = new AlertDialog.Builder(Activity); SelectSubject.SetTitle("Subjects"); SelectSubject.SetItems(data, OnClick); StartTest = new AlertDialog.Builder(Activity); StartTest.SetTitle("Warning"); StartTest.SetMessage("Are you sure?"); StartTest.SetNegativeButton("No", (sender, e) => { }); StartTest.SetPositiveButton("Yes", (sender, e) => { }); int image = Resource.Drawable.icons7; Images.SetImageResource(image); Images.Click += ClickImages; button.Click += StartClick; return(view); }
private void ValueClicked(object sender, EventArgs e) { // Verify that an attribute has been selected. if (_selectedAttribute != null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (_selectedAttribute.Domain is CodedValueDomain domain) { // Create a dialog for selecting from the coded values. builder.SetTitle("Select a value"); string[] options = domain.CodedValues.Select(x => x.Name).ToArray(); builder.SetItems(options, ValueSelected); } else { // Create a dialog for entering a value. _valueEntry = new EditText(this) { InputType = Android.Text.InputTypes.ClassNumber }; builder.SetTitle("Enter a value"); builder.SetView(_valueEntry); builder.SetPositiveButton("OK", ValueEntered); } builder.Show(); } }
static AlertDialog.Builder create(Context pContext, string pMsg, string pTitle, string[] pItems, EventHandler <DialogClickEventArgs> pHandler) { pContext = _getContext(pContext); AlertDialog.Builder alert = new AlertDialog.Builder(pContext); // alert.SetView(LayoutInflater.Inflate(Resource.Layout.msgbox, null)); alert.SetCancelable(false); if (pMsg != null) { alert.SetMessage(translate(pMsg)); } if (pTitle != null) { alert.SetTitle(translate(pTitle)); } if (pItems != null && pItems.Length > 0 && pHandler != null) { alert.SetItems(pItems, pHandler); } return(alert); }
private void showPreferencePopup() { var settings = new Settings(this); var connections = settings.GetConnections(); if (connections.Count == 0) { return; // not yet any items } string[] items = connections.Select(p => p.Server + ":" + p.Port).ToArray(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Choix du serveur"); builder.SetPositiveButton("Ajouter", delegate(object sender, DialogClickEventArgs e) { // Let the popup close and show the normal login form }); builder.SetNegativeButton("Gérer", delegate(object sender, DialogClickEventArgs e) { this.openConnectionManager(); }); builder.SetItems(items, delegate(object sender, DialogClickEventArgs e) { var index = (int)e.Which; var connection = connections[index]; this.loginAsync(connection.ServerID, connection.Server, connection.Port); }); var alert = builder.Create(); alert.Show(); }
public void ShowServingsExtraMenu() { AlertDialog.Builder builder = new AlertDialog.Builder(SupportActionBar.ThemedContext); builder.Create(); #if DEBUG1 // string[] items = new String[] { AppResources.Add, "Copy from similar" }; string[] items = new String[] { AppResources.Add }; #endif EventHandler <Android.Content.DialogClickEventArgs> eh; eh = (o, ex) => { switch (ex.Which) { case 0: vm.AddServingSize(); break; case 1: ShowAddDialog(); break; default: break; } }; builder.SetItems(items, eh); builder.Show(); }
void StartPrivateChat(object sender, EventArgs e) { var buider = new AlertDialog.Builder(this); buider.SetTitle("选择联系人"); var list = users.FindAll((obj) => { return(!obj.Equals(currentUser)); }); var names = list.ConvertAll((input) => { return(input.name); }); buider.SetItems(names.ToArray(), (object s, DialogClickEventArgs args) => { IDialogInterface dialog = s as IDialogInterface; if (dialog != null) { dialog.Dismiss(); var friend = users.Find((obj) => { return(obj.name.Equals(names[args.Which])); }); if (RongCallClient.Instance != null) { RongCallKit.StartSingleCall(this, friend.id, RongCallKit.CallMediaType.CallMediaTypeVideo); } else { ShowMsg("未连接"); } } }); buider.Show(); }
public RemoteSongsActivity() { this.WhenActivated(() => { var disposable = new CompositeDisposable(); var adapter = new ReactiveListAdapter <RemoteSongViewModel>(new ReactiveList <RemoteSongViewModel>(this.ViewModel.Songs), (vm, parent) => new RemoteSongView(this, vm, parent)); this.SongsList.Adapter = adapter; this.SongsList.Events().ItemClick.Select(x => x.Position) .Subscribe(x => { this.ViewModel.SelectedSong = this.ViewModel.Songs[x]; var items = new List <Tuple <string, IReactiveCommand> >(); if (this.ViewModel.IsAdmin) { items.Add(Tuple.Create(Resources.GetString(Resource.String.play), (IReactiveCommand)this.ViewModel.PlaySongsCommand)); items.Add(Tuple.Create(Resources.GetString(Resource.String.add_to_playlist), (IReactiveCommand)this.ViewModel.AddToPlaylistCommand)); } else if (this.ViewModel.RemainingVotes > 0) { string voteString = string.Format(Resources.GetString(Resource.String.uses_vote), this.ViewModel.RemainingVotes); items.Add(Tuple.Create(string.Format("{0} \n({1})", Resources.GetString(Resource.String.add_to_playlist), voteString), (IReactiveCommand)this.ViewModel.AddToPlaylistCommand)); } else { items.Add(Tuple.Create(Resources.GetString(Resource.String.no_votes_left), (IReactiveCommand)null)); } var builder = new AlertDialog.Builder(this); builder.SetItems(items.Select(y => y.Item1).ToArray(), (o, eventArgs) => { IReactiveCommand command = items[eventArgs.Which].Item2; if (command != null) { command.Execute(null); } }); builder.Create().Show(); }) .DisposeWith(disposable); Observable.Merge(this.ViewModel.PlaySongsCommand.Select(_ => Resource.String.playing_songs), this.ViewModel.AddToPlaylistCommand.Select(_ => Resource.String.added_to_playlist), this.ViewModel.PlaySongsCommand.ThrownExceptions.Merge(this.ViewModel.AddToPlaylistCommand.ThrownExceptions).Select(_ => Resource.String.error_adding_song)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => Toast.MakeText(this, x, ToastLength.Short).Show()) .DisposeWith(disposable); return(disposable); }); }
private void RuleClick(object sender, EventArgs e) { // Create UI for terminal selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Choose mosaic rule"); builder.SetItems(_mosaicRules.Keys.ToList().ToArray(), RuleClick); builder.Show(); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(Context); builder.SetTitle(_title); builder.SetNeutralButton(_cancel, (sender, e) => Cancel()); builder.SetItems(_buttons, (sender, e) => { _taskCompletionSource.TrySetResult(_buttons[e.Which]); }); return(builder.Create()); }
private void ChooseTraceType(object sender, EventArgs e) { // Create UI for trace type selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Select trace type"); builder.SetItems(Enum.GetNames(typeof(UtilityTraceType)), ChangeTraceType); builder.SetCancelable(true); builder.Show(); }
private void ChooseTraceType(object sender, EventArgs e) { // Create UI for trace type selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Select trace type"); builder.SetItems(new string[] { "Connected", "Subnetwork", "Upstream", "Downstream" }, ChangeTraceType); builder.SetCancelable(true); builder.Show(); }
public override void OnCreateContextMenu(IContextMenu menu, View v, IContextMenuContextMenuInfo menuInfo) { var info = (AdapterView.AdapterContextMenuInfo)menuInfo; var builder = new AlertDialog.Builder(this); builder.SetTitle(((TextView)info.TargetView).Text); builder.SetItems(new[] { "Rename", "Delete" }, new ClickListener()); builder.Show(); }
public override bool OnOptionsItemSelected(IMenuItem item) { var itemId = item.ItemId; switch (itemId) { case MENU_MAP_TYPE: { //String hdMapTile = mMapView.isHDMapTileEnabled()? "HD Map Tile Off" : "HD Map Tile On"; string hdMapTile; if (mMapView.TileMode == MapTileMode.Hd2x) { hdMapTile = "Set to Standard Mode"; } else if (mMapView.TileMode == MapTileMode.Hd) { hdMapTile = "Set to HD 2X Mode"; } else { hdMapTile = "Set to HD Mode"; } string[] mapTypeMenuItems = { "Standard", "Satellite", "Hybrid", hdMapTile, "Clear Map Tile Cache" }; AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.SetTitle("MapType"); dialog.SetItems(mapTypeMenuItems, (object sender, DialogClickEventArgs e) => { ControlMapTile(e.Which); }); dialog.Show(); return(true); } case MENU_MAP_MOVE: { string rotateMapMenu = mMapView.MapRotationAngle.Equals(0.0f) ? "Rotate Map 60" : "Unrotate Map"; string[] mapMoveMenuItems = { "Move to", "Zoom to", "Move and Zoom to", "Zoom In", "Zoom Out", rotateMapMenu }; AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.SetTitle("Move"); dialog.SetItems(mapMoveMenuItems, (object sender, DialogClickEventArgs e) => { ControlMapMove(e.Which); }); dialog.Show(); return(true); } } return(base.OnOptionsItemSelected(item)); }
private void Btn_dev_LongClick(object sender, Android.Views.View.LongClickEventArgs e) { if (mqttClient != null && mqttClient.IsConnected) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle(Resource.String.question); alert.SetItems(new string[] { GetString(Resource.String.qyes), GetString(Resource.String.qno), GetString(Resource.String.qdelete), GetString(Resource.String.qcancel) }, (senderAlert, args) => { if (args.Which == 0) { mqttClient.Publish(((DevInfo)(((Button)sender).Tag)).ID + "/control/", System.Text.Encoding.UTF8.GetBytes("RESET")); } if (args.Which == 1) { mqttClient.Publish(((DevInfo)(((Button)sender).Tag)).ID + "/control/", System.Text.Encoding.UTF8.GetBytes("UPDATE")); } if (args.Which == 2) { List <DevInfo> dev_list_saved; var prefs = Application.Context.GetSharedPreferences("SmartHomeApp", FileCreationMode.Private); string dev_list_saved_json = prefs.GetString("DEVINFO", null); if (dev_list_saved_json == null) { dev_list_saved = new List <DevInfo>(); } else { dev_list_saved = JsonConvert.DeserializeObject <List <DevInfo> >(dev_list_saved_json); } foreach (DevInfo s in dev_list_saved.ToList()) { if (s.ID == ((DevInfo)((Button)sender).Tag).ID) { dev_list_saved.Remove(s); } } string stringjson = JsonConvert.SerializeObject(dev_list_saved); var prefEditor = prefs.Edit(); prefEditor.PutString("DEVINFO", stringjson); prefEditor.Commit(); AddModules(); } if (args.Which == 3) { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); } }); Dialog dialog = alert.Create(); dialog.Show(); } }
public void AddPlayer() { if (playersInfo.Count < MaxPlayerCount) { EditText et = (EditText)LayoutInflater.Inflate(Resource.Layout.edittext_dialog, null, false); AlertDialog.Builder ad = new AlertDialog.Builder(this); et.Text = GetFreeName(); ad.SetTitle("Player's name"); ad.SetView(et); var dialog = ad.Create(); et.KeyPress += (sender, e) => { if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) { string name = et.Text; HideKeyboard(et); dialog.Dismiss(); ad = new AlertDialog.Builder(this); ad.SetTitle("Player's type"); dialog = ad.Create(); ad.SetItems(System.Enum.GetValues(typeof(PlayerType)).Cast <PlayerType>().Select(_ => _.ToString()).ToArray(), (sender2, e2) => { playersInfo.Add(new PlayerInfo(et.Text, (PlayerType)e2.Which)); ((AlertDialog)sender2).Dismiss(); adapter.NotifyDataSetChanged(); }); ad.Show(); } else { e.Handled = false; } }; dialog.Show(); //dialog.DismissEvent += (a, b) => { HideKeyboard(et); }; et.SelectAll(); ShowKeyboard(et); } void ShowKeyboard(View pView) { pView.RequestFocus(); InputMethodManager inputMethodManager = GetSystemService(InputMethodService) as InputMethodManager; inputMethodManager.ShowSoftInput(pView, ShowFlags.Forced); inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly); } void HideKeyboard(View pView) { InputMethodManager inputMethodManager = GetSystemService(InputMethodService) as InputMethodManager; inputMethodManager.HideSoftInputFromWindow(pView.WindowToken, HideSoftInputFlags.None); } }
private void ShowResetOptions() { string[] options = new string[] { "Under", "Over", "Always", "Never" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetItems(options, new AlertDialogClick(demoView)); builder.Create().Show(); }
public static void DisplayListPrompt(Context aContext, List <IListPrompt> aItems, EventHandler <DialogClickEventArgs> aOnSelectHandler) { AlertDialog.Builder lBuilder = new AlertDialog.Builder(aContext); lBuilder.SetTitle(Resource.String.choose); lBuilder.SetItems(aItems.Select(x => x.Text).ToArray(), aOnSelectHandler); AlertDialog lDlg = lBuilder.Create(); lDlg.Window.SetBackgroundDrawableResource(Resource.Drawable.default_dialog); lDlg.Show(); }
private void OnPhotoButtonClicked(object sender, EventArgs e) { var optionsArray = new string[] { "Camera", "Gallery" }; _alert = new AlertDialog.Builder(this); _alert.SetTitle(GetString(Resource.String.DetailsDefaultTitle)); _alert.SetItems(optionsArray, UploadFrom); _alert.SetNegativeButton(GetString(Resource.String.PhotoAlertButton), CloseUpload); _alert.Show(); }
//public static FloatingActionButton AddFab(Context context,Bitmap icon) //{ // FloatingActionButton fab = new FloatingActionButton(context); // fab.SetForegroundGravity(GravityFlags.Bottom | GravityFlags.Right); // fab.SetImageIcon(Icon.CreateWithBitmap(icon)); // fab.SetRippleColor(Color.BlueViolet); // return fab; //} public static void ShowChooserDialog(Context context, string[] options, Action <int> action) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("Pick a color"); builder.SetItems(options, (sender, e) => { action(e.Which); }); builder.Show(); }
private void Add_Click(object sender, EventArgs e) { string[] options = new string[] { "Point", "Polyline", "Polygon" }; // Create UI for terminal selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetItems(options, Draw); builder.SetCancelable(false); builder.Show(); }
private void SelectStorage_Click(object sender, EventArgs e) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Lager für Neuanlage"); builder.SetItems(this.Storages.ToArray(), (s, a) => { var textView = FindViewById <AutoCompleteTextView>(Resource.Id.StorageItemQuantity_StorageText); textView.Text = this.Storages[a.Which]; }); builder.Show(); }
public void SetItems(string[] items, EventHandler <DialogClickEventArgs> handler) { if (_useAppCompat) { _appcompatBuilder.SetItems(items, handler); } else { _legacyBuilder.SetItems(items, handler); } }
void ItemLongClick(string tag, int position) { if (userInfo.DisplayName == answerList[position].UserName) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetCancelable(true); string[] btns = new string[] { "ɾ³ý", "ÐÞ¸Ä" }; int answerId = int.Parse(tag); builder.SetItems(btns, (s, e) => { if (e.Which == 0) { ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner); progressDialog.SetMessage("ɾ³ýÖÐ...."); if (userToken.IsExpire) { Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("µÇ¼Ìáʾ") .SetMessage("δµÇ¼»òµÇ¼tokenÒѾ¹ýÆÚ") .SetPositiveButton("ÊÚȨ", (s1, e1) => { StartActivity(new Intent(this, typeof(loginactivity))); }) .SetNegativeButton("È¡Ïû", (s1, e1) => { return; }); alertDialog.Create().Show(); } progressDialog.Show(); QuestionService.DeleteQuestionAnswer(userToken, questionId, answerId, (error) => { RunOnUiThread(() => { progressDialog.Hide(); AlertUtil.ToastShort(this, "ɾ³ý»Ø´ðʧ°Ü" + error); }); }, () => { RunOnUiThread(() => { progressDialog.Hide(); AlertUtil.ToastShort(this, "ɾ³ý»Ø´ð³É¹¦"); }); }); } else if (e.Which == 1) { QuestionEditAnswerActivity.Enter(this, questionId, answerId, answerList[position].Answer); } }).Show(); } }
public void OnClick(View v) { _lastClickedColorId = v.Id; AlertDialog.Builder builder = new AlertDialog.Builder(Activity); builder.SetTitle("Kies een kleur."); builder.SetItems(_colors, OnColorClick); Dialog dialog = builder.Create(); dialog.Show(); }
private void ComparisonClicked(object sender, EventArgs e) { // Get the names of every comparison operator. string[] options = Enum.GetNames(typeof(UtilityAttributeComparisonOperator)); // Create UI for attribute selection. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Select comparison"); builder.SetItems(options, ComparisonSelected); builder.Show(); }