zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    【项目管理】git和码云的使用
    【Yii系列】处理请求
    【Yii系列】Yii2.0基础框架
    JDBC Java 程序从 MySQL 数据库中读取数据,并备份到 xml 文档中
    Java 把一个文本文档的内容复制到另一个文本文档
    Java 写一段字符到指定的文本文档中,如果该文本文档不存在,则创建该文本文档
    Java 单字节、多字节读取文本文档中的内容
    Java File mkdir() mkdirs()
    JDBC Java 程序从 MySQL 数据库中读取数据,并封装到 Javabean 对象中
    Java int类型与String类型互转
  • 原文地址:https://www.cnblogs.com/Cindys/p/2728099.html
Copyright © 2011-2022 走看看