public static Task <JwtLoginCredentials> GetInputAsync(string title) { var context = GetContext(); var tcs = new TaskCompletionSource <JwtLoginCredentials>(); var result = new JwtLoginCredentials(); AlertDialog dialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle(title); var viewInflated = LayoutInflater.From(context).Inflate(Resource.Layout.login_view, null, false); var userInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_user); var passwordInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_password); builder.SetView(viewInflated); builder.SetOnCancelListener(new DialogInterfaceOnCancelListener(() => tcs.TrySetResult(null))); builder.SetOnDismissListener(new DialogInterfaceOnDismissListener(() => tcs.TrySetResult(null))); builder.SetPositiveButton(Android.Resource.String.Ok, (sender, args) => { result.User = userInput.Text; result.Password = passwordInput.Text; tcs.TrySetResult(result); dialog.Dismiss(); }); builder.SetNegativeButton(Android.Resource.String.Cancel, (sender, args) => { tcs.TrySetResult(null); dialog.Cancel(); }); dialog = builder.Show(); return(tcs.Task); }
void OnActionSheetRequested(Page sender, ActionSheetArguments arguments) { // Verify that the page making the request is part of this activity if (!PageIsInThisContext(sender)) { return; } var builder = new AlertDialog.Builder(Activity); builder.SetTitle(arguments.Title); string[] items = arguments.Buttons.ToArray(); builder.SetItems(items, (o, args) => arguments.Result.TrySetResult(items[args.Which])); if (arguments.Cancel != null) { builder.SetPositiveButton(arguments.Cancel, (o, args) => arguments.Result.TrySetResult(arguments.Cancel)); } if (arguments.Destruction != null) { builder.SetNegativeButton(arguments.Destruction, (o, args) => arguments.Result.TrySetResult(arguments.Destruction)); } AlertDialog dialog = builder.Create(); builder.Dispose(); //to match current functionality of renderer we set cancelable on outside //and return null dialog.SetCanceledOnTouchOutside(true); dialog.CancelEvent += (o, e) => arguments.SetResult(null); dialog.Show(); }
private void ItemOptionsClick(object sender, int position) { if (position < 0) { return; } var builder = new AlertDialog.Builder(this); builder.SetItems(Resource.Array.authContextMenu, (alertSender, args) => { switch (args.Which) { case 0: OpenRenameDialog(position); break; case 1: OpenIconDialog(position); break; case 2: OpenCategoriesDialog(position); break; case 3: OpenDeleteDialog(position); break; } }); var dialog = builder.Create(); dialog.Show(); }
/// <summary> /// Show Reaction dialog when user long click on react button /// </summary> public void ClickDialog(CommentReplyClickEventArgs postData) { try { PostData = postData; //Show Dialog With 6 React AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainContext); //Irrelevant code for customizing the buttons and title LayoutInflater inflater = (LayoutInflater)MainContext.GetSystemService(Context.LayoutInflaterService); View dialogView = inflater?.Inflate(Resource.Layout.XReactDialogLayout, null); InitializingReactImages(dialogView); ClickImageButtons(); dialogBuilder.SetView(dialogView); MReactAlertDialog = dialogBuilder.Create(); MReactAlertDialog.Window?.SetBackgroundDrawableResource(MReactDialogShape); Window window = MReactAlertDialog.Window; window?.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); MReactAlertDialog.Show(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public Task <bool> ShowAlertAsync(string title, string message, string okButtonText, string?cancelButtonText = null) { var tcs = new TaskCompletionSource <bool>(); Execute.BeginOnUIThread(() => { var context = Dependencies.Container.Resolve <IContextProvider>().CurrentActivity; var builder = new AlertDialog.Builder(context) .SetTitle(title) .SetMessage(message); SetPositiveButton(builder, okButtonText, tcs, true); if (cancelButtonText != null) { SetNegativeButton(builder, cancelButtonText, tcs, false); } var dialog = builder.Create(); var dismissCommand = new RelayCommand <TaskCompletionSource <bool> >(x => { x.TrySetResult(false); }); dialog.SetCommand(nameof(dialog.DismissEvent), dismissCommand, tcs); dialog.Show(); }); return(tcs.Task); }
/// <summary> /// Show Reaction dialog when user long click on react button /// </summary> public void LongClickDialog(GlobalClickEventArgs postData, NativePostAdapter nativeFeedAdapter, string namePage = "") { try { PostData = postData; NamePage = namePage; NativeFeedAdapter = nativeFeedAdapter; //Show Dialog With 6 React AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Context); //Irrelevant code for customizing the buttons and title LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); View dialogView = inflater.Inflate(Resource.Layout.XReactDialogLayout, null); InitializingReactImages(dialogView); SetReactionsArray(); ResetReactionsIcons(); ClickImageButtons(); dialogBuilder.SetView(dialogView); MReactAlertDialog = dialogBuilder.Create(); MReactAlertDialog.Window?.SetBackgroundDrawableResource(MReactDialogShape); Window window = MReactAlertDialog.Window; window?.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); MReactAlertDialog.Show(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void TagsButton_Click(object sender, EventArgs e) { var dialog = new AlertDialog.Builder(_context, _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create(); var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null); var recycler = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView); dialog.SetView(dialogView); var tags = _presenter.GetMediaTags().OrderBy(x => x.Name).Select(x => new CheckBoxItemRecyclerAdapter.CheckBoxItem { Title = x.Name, Description = x.Description, IsChecked = _selectedTags?.Any(y => y == x.Name) == true }).ToList(); var adapter = new CheckBoxItemRecyclerAdapter(_context, tags) { ToggleDescription = true }; recycler.SetAdapter(adapter); dialog.Show(); dialog.DismissEvent += (disSender, disArgs) => { _selectedTags = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList(); SetupTagsButton(_tagsButton); }; }
private void StreamingOnButton_Click(object sender, EventArgs e) { var dialog = new AlertDialog.Builder(_context, _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create(); var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null); var recycler = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView); dialog.SetView(dialogView); var licensees = AniListEnum.GetEnumValues <MediaLicensee>().Select(x => new CheckBoxItemRecyclerAdapter.CheckBoxItem { Title = x.DisplayValue, IsChecked = _selectedStreamingOn?.Any(y => y == x.DisplayValue) == true }).ToList(); var adapter = new CheckBoxItemRecyclerAdapter(_context, licensees); recycler.SetAdapter(adapter); dialog.Show(); dialog.DismissEvent += (disSender, disArgs) => { _selectedStreamingOn = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList(); SetupStreamingOnButton(_streamingOnButton); }; }
private void GenresButton_Click(object sender, EventArgs e) { var dialog = new AlertDialog.Builder(_context, _context.GetThemedResourceId(Resource.Attribute.Dialog_Theme)).Create(); var dialogView = _context.LayoutInflater.Inflate(Resource.Layout.View_List, null); var recycler = dialogView.FindViewById <RecyclerView>(Resource.Id.List_RecyclerView); dialog.SetView(dialogView); var genres = _genres.OrderBy(x => x).Select(x => new CheckBoxItemRecyclerAdapter.CheckBoxItem { Title = x, IsChecked = _selectedGenres?.Any(y => y == x) == true }).ToList(); var adapter = new CheckBoxItemRecyclerAdapter(_context, genres); recycler.SetAdapter(adapter); dialog.Show(); dialog.DismissEvent += (disSender, disArgs) => { _selectedGenres = adapter.Items.Where(x => x.IsChecked).Select(x => x.Title).ToList(); SetupGenresButton(_genresButton); }; }
private async Task Init() { try { _connection = await Database.Connect(this); InitCategories(); InitAuthenticators(); await UpdateCategories(false); await UpdateAuthenticators(false); CreateTimer(); } catch (SQLiteException) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.databaseError); builder.SetTitle(Resource.String.warning); builder.SetPositiveButton(Resource.String.quit, (sender, args) => { Finish(); }); builder.SetCancelable(true); var dialog = builder.Create(); dialog.Show(); } }
/// <summary> /// ShowMessage /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="firstButtonContent"></param> /// <param name="nextButtonContent"></param> /// <param name="lastButtonContent"></param> /// <returns></returns> public async Task <ButtonDialog> ShowMessage(string title, string message, string firstButtonContent, string nextButtonContent, string lastButtonContent) { var tcs = new TaskCompletionSource <ButtonDialog>(); var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle); builder.SetTitle(title) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Primary); }) .SetNeutralButton(lastButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Close); }) .SetNegativeButton(nextButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Secondary); }); var alert = builder.Create(); alert.Show(); var btnPositive = alert.GetButton((int)DialogButtonType.Positive); var btnNegative = alert.GetButton((int)DialogButtonType.Negative); var btnNeutral = alert.GetButton((int)DialogButtonType.Neutral); var layoutParams = (LinearLayout.LayoutParams)btnPositive.LayoutParameters; layoutParams.Gravity = GravityFlags.Center; btnPositive.LayoutParameters = layoutParams; btnNegative.LayoutParameters = layoutParams; btnNeutral.LayoutParameters = layoutParams; return(await tcs.Task); }
private void FindByIson() { _countryPicker = new CountryPicker.Builder().With(this).Listener(this).Build(); var builder = new AlertDialog.Builder(this, R.Style.Base_Theme_MaterialComponents_Dialog_Alert); var input = new EditText(this) { InputType = InputTypes.ClassText | InputTypes.TextVariationPassword }; builder.SetTitle("Country Code") .SetView(input) .SetCancelable(false) .SetPositiveButton( textId: Android.Resource.String.Ok, handler: (sender, args) => { var country = _countryPicker.GetCountryByISO(input.Text); if (country == null) { ShowToast("Country not found"); } else { ShowResultActivity(country); } } ).SetNegativeButton( textId: Android.Resource.String.Cancel, handler: (sender, args) => (sender as IDialogInterface)?.Cancel() ).Show(); }
public Dialog Build(AppCompatActivity activity, PromptConfig config) { var txt = new EditText(activity) { Id = Int32.MaxValue, Hint = config.Placeholder }; if (config.Text != null) { txt.Text = config.Text; txt.SetSelection(config.Text.Length); } if (config.MaxLength != null) { txt.SetFilters(new[] { new InputFilterLengthFilter(config.MaxLength.Value) }); } SetInputType(txt, config.InputType); if (config.AutoCorrectionConfig != AutoCorrectionConfig.Default) { switch (config.AutoCorrectionConfig) { case AutoCorrectionConfig.No: txt.InputType |= InputTypes.TextFlagNoSuggestions; // Add Flag break; case AutoCorrectionConfig.Yes: txt.InputType &= ~InputTypes.TextFlagNoSuggestions; // Remove Flag break; default: break; } } var builder = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetView(txt) .SetPositiveButton(config.OkText, (s, a) => config.OnAction(new PromptResult(true, txt.Text.Trim())) ); if (config.IsCancellable) { builder.SetNegativeButton(config.CancelText, (s, a) => config.OnAction(new PromptResult(false, txt.Text.Trim())) ); } var dialog = builder.Create(); this.HookTextChanged(dialog, txt, config); return(dialog); }
public void ShowMessageDialog(string title, string message) { AlertDialog ad = new AlertDialog.Builder(this) .SetTitle(title) .SetMessage(message) .Create(); ad.Show(); }
public void OnReceiveMessage(string message) { System.Diagnostics.Debug.WriteLine($"{nameof(OnReceiveMessage)}"); var alert = new AlertDialog.Builder(this) .SetTitle("Message") .SetMessage(message) .SetPositiveButton("OK", (sender, args) => { }) .Create(); alert.Show(); }
public DialogBuilder(Activity activity) { if (activity is AppCompatActivity) { _appcompatBuilder = new AppCompatAlertDialog.Builder(activity); _useAppCompat = true; } else { _legacyBuilder = new AlertDialog.Builder(activity); } }
protected virtual void ConfigureDialogBuilder(AndroidX_AlertDialog.Builder builder) { if (ShouldConfigureToBuilder(nameof(Config.Title))) { builder.SetTitle(Config.Title); } if (ShouldConfigureToBuilder(nameof(Config.Message))) { builder.SetMessage(Config.Message); } }
/// <summary> /// ShowMessage /// </summary> /// <returns></returns> public async Task <string> ShowInputDialog(string title, string hint = null, string messageInput = null, // ReSharper disable once MethodOverloadWithOptionalParameter DialogInputType type = DialogInputType.None, bool isEmpty = false) { var tcs = new TaskCompletionSource <string>(); CrossCurrentActivity.Current.Activity.RunOnUiThread(() => { var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity); var input = new EditText(CrossCurrentActivity.Current.Activity); var lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); lp.SetMargins((int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0, (int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0); input.LayoutParameters = lp; input.SetMaxLines(1); input.SetSingleLine(true); input.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(25) }); input.Text = string.IsNullOrEmpty(messageInput) || isEmpty ? string.Empty : messageInput; input.Hint = string.IsNullOrEmpty(messageInput) && !string.IsNullOrEmpty(hint) ? hint : string.Empty; input.InputType = GetInputType(type); var view = new LinearLayout(CrossCurrentActivity.Current.Activity); var lpView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); view.LayoutParameters = lpView; view.AddView(input); view.Touch += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); view.Click += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); var dlg = new Dialog(CrossCurrentActivity.Current.Activity); var dlg1 = dlg; builder.SetTitle(title) .SetView(view) .SetPositiveButton("OK", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(input.Text); dlg1.Dismiss(); }) .SetNegativeButton("Cancel", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(null); dlg1.Dismiss(); }); dlg = builder.Create(); dlg.Show(); }); return(await tcs.Task); }
private void ShowDialogButton_Click(object sender, EventArgs e) { _builder = new AndroidX.AppCompat.App.AlertDialog.Builder(this); LayoutInflater inflater = this.LayoutInflater; View dialogView = inflater.Inflate(Resource.Layout.layout_loading_dialog, null); _builder.SetView(dialogView); _loadingDialog = _builder.Create(); _loadingProgressMessageTextView = dialogView.FindViewById <TextView>(Resource.Id.loadingProgressMessageTextView); _loadingProgressMessageTextView.Text = "This is loading"; MoveDialogToRightTopCorner(); _loadingDialog.Show(); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.chooseCategories); alert.SetCancelable(false); alert.SetPositiveButton(Resource.String.ok, (EventHandler <DialogClickEventArgs>)null); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChooseCategories, null); _categoryList = view.FindViewById <RecyclerView>(Resource.Id.dialogChooseCategories_list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); var layout = new LinearLayoutManager(Context); var decoration = new DividerItemDecoration(Context, layout.Orientation); _categoryList.AddItemDecoration(decoration); _categoryList.SetLayoutManager(layout); _categoryAdapter = new ChooseCategoriesAdapter(_categorySource); _categoryAdapter.ItemClick += _itemClick; _categoryList.SetAdapter(_categoryAdapter); _categoryList.HasFixedSize = true; _categoryList.SetItemViewCacheSize(20); var okButton = dialog.GetButton((int)DialogButtonType.Positive); okButton.Click += _onClose.Invoke; var emptyText = view.FindViewById <TextView>(Resource.Id.dialogChooseCategories_empty); if (_categorySource.Count() == 0) { emptyText.Visibility = ViewStates.Visible; _categoryList.Visibility = ViewStates.Gone; } foreach (var category in _checkedCategories) { var index = _categorySource.Categories.FindIndex(c => c.Id == category); _categoryAdapter.CheckedStatus[index] = true; } return(dialog); }
private async Task Init() { var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>(); var micStatus = await Permissions.RequestAsync <Permissions.Microphone>(); _webRtcClient = new WebRtcClient(this, _remoteView, _localView, this); var dialogTcs = new TaskCompletionSource <string>(); var linearLayout = new LinearLayout(this); linearLayout.Orientation = Orientation.Vertical; linearLayout.SetPadding(48, 24, 48, 24); var ipAddr = new EditText(this) { Hint = "IP Address", Text = "192.168.1.119" }; var port = new EditText(this) { Hint = "Port", Text = "8080" }; linearLayout.AddView(ipAddr); linearLayout.AddView(port); var alert = new AlertDialog.Builder(this) .SetTitle("Socket Address") .SetView(linearLayout) .SetPositiveButton("OK", (sender, args) => { dialogTcs.TrySetResult($"ws://{ipAddr.Text}:{port.Text}"); }) .Create(); alert.Show(); var wsUrl = await dialogTcs.Task; var okHttpClient = new OkHttpClient.Builder() .ReadTimeout(0, Java.Util.Concurrent.TimeUnit.Milliseconds) .Build(); var request = new Request.Builder() .Url(wsUrl) .Build(); _socket = okHttpClient.NewWebSocket( request, new WebSocketObserver(ReadMessage)); }
/// <summary> /// ShowMessage /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="firstButtonContent"></param> /// <returns></returns> public async Task <bool?> ShowMessage(string title, string message, string firstButtonContent) { var tcs = new TaskCompletionSource <bool?>(); var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle); builder.SetTitle(title) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(true); }); builder.Create().Show(); return(await tcs.Task); }
void OnPromptRequested(Page sender, PromptArguments arguments) { // Verify that the page making the request is part of this activity if (!PageIsInThisContext(sender)) { return; } AlertDialog alertDialog = new AlertDialog.Builder(Activity).Create(); alertDialog.SetTitle(arguments.Title); alertDialog.SetMessage(arguments.Message); var frameLayout = new FrameLayout(Activity); var editText = new EditText(Activity) { Hint = arguments.Placeholder, Text = arguments.InitialValue }; var layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { LeftMargin = (int)(22 * Activity.Resources.DisplayMetrics.Density), RightMargin = (int)(22 * Activity.Resources.DisplayMetrics.Density) }; editText.LayoutParameters = layoutParams; editText.InputType = arguments.Keyboard.ToInputType(); if (arguments.Keyboard == Keyboard.Numeric) { editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType); } if (arguments.MaxLength > -1) { editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(arguments.MaxLength) }); } frameLayout.AddView(editText); alertDialog.SetView(frameLayout); alertDialog.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(editText.Text)); alertDialog.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(null)); alertDialog.CancelEvent += (o, args) => { arguments.SetResult(null); }; alertDialog.Window.SetSoftInputMode(SoftInput.StateVisible); alertDialog.Show(); editText.RequestFocus(); }
private void OpenDeleteDialog(int position) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.confirmAuthenticatorDelete); builder.SetTitle(Resource.String.warning); builder.SetPositiveButton(Resource.String.delete, async(sender, args) => { await _authSource.Delete(position); _authAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); builder.SetCancelable(true); var dialog = builder.Create(); dialog.Show(); }
private void EnableDeviceAdmin_Click(object sender, EventArgs e) { if (Checkers.IsThisAppADeviceAdministrator()) { ComponentName devAdminReceiver = new ComponentName(Application.Context, Java.Lang.Class.FromType(typeof(AdminReceiver))); DevicePolicyManager dpm = (DevicePolicyManager)GetSystemService(Context.DevicePolicyService); dpm.RemoveActiveAdmin(devAdminReceiver); } else { using (AlertDialog.Builder builder = new AlertDialog.Builder(this)) { builder.SetMessage(Resource.String.dialogfordeviceaccessdescription); builder.SetPositiveButton(Resource.String.dialogallowbutton, new EventHandler <DialogClickEventArgs>(OnDialogPositiveButtonEventArgs)); builder.SetNegativeButton(Resource.String.dialogcancelbutton, null as EventHandler <DialogClickEventArgs>); builder.Show(); } } }
public override Android.App.Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.changeIcon); alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); alert.SetCancelable(false); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogChangeIcon, null); _searchText = view.FindViewById <EditText>(Resource.Id.editSearch); _iconList = view.FindViewById <RecyclerView>(Resource.Id.list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); _searchText.TextChanged += OnSearchChanged; _iconListAdapter = new IconListAdapter(Context, _iconSource); _iconListAdapter.ItemClick += OnItemClick; _iconListAdapter.HasStableIds = true; _iconList.SetAdapter(_iconListAdapter); _iconList.HasFixedSize = true; _iconList.SetItemViewCacheSize(20); var layout = new FixedGridLayoutManager(Context, 6); _iconList.SetLayoutManager(layout); var cancelButton = dialog.GetButton((int)DialogButtonType.Negative); cancelButton.Click += (sender, e) => { dialog.Dismiss(); }; return(dialog); }
void OnAlertRequested(Page sender, AlertArguments arguments) { // Verify that the page making the request is part of this activity if (!PageIsInThisContext(sender)) { return; } AlertDialog alert = new AlertDialog.Builder(Activity).Create(); alert.SetTitle(arguments.Title); alert.SetMessage(arguments.Message); if (arguments.Accept != null) { alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true)); } alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false)); alert.CancelEvent += (o, args) => { arguments.SetResult(false); }; alert.Show(); }
public Dialog Build(AppCompatActivity activity, PromptConfig config) { var txt = new EditText(activity) { Id = Int32.MaxValue, Hint = config.Placeholder }; if (config.Text != null) { txt.Text = config.Text; txt.SetSelection(config.Text.Length); } if (config.MaxLength != null) { txt.SetFilters(new[] { new InputFilterLengthFilter(config.MaxLength.Value) }); } SetInputType(txt, config.InputType); var builder = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetView(txt) .SetPositiveButton(config.OkText, (s, a) => config.OnAction(new PromptResult(true, txt.Text.Trim())) ); if (config.IsCancellable) { builder.SetNegativeButton(config.CancelText, (s, a) => config.OnAction(new PromptResult(false, txt.Text.Trim())) ); } var dialog = builder.Create(); this.HookTextChanged(dialog, txt, config); return(dialog); }
private void OnDeleteClick(object item, int position) { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.confirmCategoryDelete); builder.SetTitle(Resource.String.warning); builder.SetCancelable(true); builder.SetPositiveButton(Resource.String.delete, async(sender, args) => { await _categorySource.Delete(position); _categoryAdapter.NotifyItemRemoved(position); CheckEmptyState(); }); builder.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); var dialog = builder.Create(); dialog.Show(); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var alert = new AlertDialog.Builder(Activity); alert.SetTitle(Resource.String.changeIcon); alert.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); alert.SetCancelable(false); var view = Activity.LayoutInflater.Inflate(Resource.Layout.dialogIcon, null); _searchText = view.FindViewById <EditText>(Resource.Id.dialogIcon_search); _iconList = view.FindViewById <RecyclerView>(Resource.Id.dialogIcon_list); alert.SetView(view); var dialog = alert.Create(); dialog.Show(); dialog.Window.SetSoftInputMode(SoftInput.StateAlwaysVisible); _searchText.TextChanged += SearchChanged; _iconAdapter = new IconAdapter(Context, _iconSource); _iconAdapter.ItemClick += ItemClick; _iconAdapter.SetHasStableIds(true); _iconList.SetAdapter(_iconAdapter); _iconList.HasFixedSize = true; _iconList.SetItemViewCacheSize(20); var layout = new AuthListGridLayoutManager(Context, 6); _iconList.SetLayoutManager(layout); var cancelButton = dialog.GetButton((int)DialogButtonType.Negative); cancelButton.Click += _negativeButtonEvent.Invoke; return(dialog); }