Example #1
0
        public static void ShowTwoButtonAlert(this Activity scope, string title, int firstButton, int secondButton, Action firstHandler, Action secondHandler)
        {
            var custom_title = new TextView(scope);

            custom_title.Text = title;
            custom_title.SetBackgroundColor(Color.Rgb(51, 109, 97));
            custom_title.SetPadding(10, 10, 10, 10);
            custom_title.Gravity = Android.Views.GravityFlags.Center;
            custom_title.SetTextColor(Color.White);
            custom_title.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

            var builder = new AlertDialog.Builder(scope)
                          .SetNegativeButton(AndroidLocalizator.Translate(firstButton), (s, e) => scope.RunOnUiThread(firstHandler))
                          .SetPositiveButton(AndroidLocalizator.Translate(secondButton), (s, e) => scope.RunOnUiThread(secondHandler))
                          .SetCustomTitle(custom_title)
                          .Show();

            builder.Window.SetBackgroundDrawableResource(Resource.Drawable.solid_shape);

            var btnwidth    = (int)(scope.Resources.DisplayMetrics.WidthPixels / 2 - 40 * scope.Resources.DisplayMetrics.Density);
            var buttonFirst = builder.FindViewById <Button>(Android.Resource.Id.Button2);

            buttonFirst.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
            buttonFirst.LayoutParameters = new LinearLayout.LayoutParams(btnwidth, Android.Views.ViewGroup.LayoutParams.WrapContent);
            buttonFirst.SetBackgroundResource(Resource.Drawable.right_button_border);
            buttonFirst.Gravity = Android.Views.GravityFlags.Center;

            var buttonSecond = builder.FindViewById <Button>(Android.Resource.Id.Button1);

            buttonSecond.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
            buttonSecond.LayoutParameters = new LinearLayout.LayoutParams(btnwidth, Android.Views.ViewGroup.LayoutParams.WrapContent);

            buttonSecond.Gravity = Android.Views.GravityFlags.Center;
        }
Example #2
0
        public static ProgressDialog ShowProgress(this Activity scope)
        {
            var mDialog = new ProgressDialog(scope);

            mDialog.SetMessage(AndroidLocalizator.Translate(Resource.String.MESSAGE_LOAD_DATA));
            mDialog.SetCancelable(false);
            mDialog.Show();

            return(mDialog);
        }
Example #3
0
 public static void ShowWarning(this Activity scope, string message)
 {
     ShowOneButtonAlert(scope, AndroidLocalizator.Translate(Constants.TITLE_DELETE), message);
 }
Example #4
0
 public static void ShowError(this Activity scope, string message)
 {
     ShowOneButtonAlert(scope, AndroidLocalizator.Translate(Constants.TITLE_ERROR), message);
 }