Mono for Android Dialog 对话框

简洁弹出方式:

Toast.MakeText(mContext, "Hello", ToastLength.Short).Show(); 

 

使用.net开发安卓,以下是  AlertDialog与ProgressDialog的使用

#region AlertDialog

        public static void AlertDialog(Context ctx, string title, string msg)
        {
            AlertDialog.Builder ad = new AlertDialog.Builder(ctx);
            ad.SetTitle(title);
            //ad.SetTitle(Android.Resource.String.DialogAlertTitle);
            ad.SetMessage(msg);
            ad.SetIcon(Android.Resource.Drawable.IcDialogInfo);

            EditText inputServer = new EditText(ctx);
            ad.SetView(inputServer);

            ad.SetPositiveButton("OK", (sender, e) =>
            {
                ad.Dispose();
            });
            ad.SetNegativeButton("NO", (sender, e) =>
            {
                ad.Dispose();
            });
            ad.SetCancelable(true);

            ad.Show();
        }

        /// <summary>
        /// CustomDialog
        /// </summary>
        public void AlertDialogWithEditText(Context ctx)
        {
            AlertDialog.Builder ad = new AlertDialog.Builder(ctx);
            ad.SetTitle(" ");
            ad.SetMessage("Please enter password.");
            ad.SetIcon(Android.Resource.Drawable.IcDialogInfo);

            EditText inputServer = new EditText(ctx);
            inputServer.InputType = Android.Text.InputTypes.TextVariationPassword;
            ad.SetView(inputServer);

            ad.SetPositiveButton("OK", (sender, e) =>
            {
                ad.Dispose();
            });

            ad.SetNegativeButton("Cancel", (sender, e) =>
            {
                ad.Dispose();
            });

            ad.SetCancelable(true);
            ad.Show();
        }

        #endregion

        #region ProgressDialog

        //滚动轮
        public static void SpinnerProgressDialog(Context ctx, string title, string message)
        {
            // ProgressDialog pd = ProgressDialog.Show(ctx, new Java.Lang.String(title.ToString()), new Java.Lang.String(message.ToString()), true);
            ProgressDialog pd = new ProgressDialog(ctx);
            pd.SetTitle(title);
            pd.SetMessage(message);

            //滚动进度在此设置不起作用
            pd.SetProgressStyle(ProgressDialogStyle.Spinner);
            pd.SetIcon(Android.Resource.Drawable.ButtonDefault);
            pd.Show();
        }

        //横向滚动条
        public static void HorizontalProgressDialog(Context ctx, string title, string message)
        {
            ProgressDialog pd = new ProgressDialog(ctx);
            pd.SetTitle("");
            pd.SetMessage("loading");
            pd.SetIcon(Android.Resource.Drawable.ButtonDefault);

            //设置滚动进度
   pd.IncrementProgressBy(50);
            pd.SetProgressStyle(ProgressDialogStyle.Horizontal);
            pd.Show();
        }

        #endregion

转载于:https://www.cnblogs.com/Cindys/archive/2012/10/17/2728099.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值