安卓自定义AlertDialog弹出框

SystemAlertDialogManager 类

public class SystemAlertDialogManager : Activity
    {
        private Dialog mDialog;
        private Button mYes;
        private Button mNo;
        private Context mContext;
        private TextView tvTitle;
        public SystemAlertDialogManager(Context context)
        {
            this.mContext = context;
        }
        public void ShowRecordingDialog(string remind, string yes, string no)
        {
            this.mDialog = new Dialog(mContext, Resource.Style.SystemAlertDialog);
            this.mDialog.RequestWindowFeature((int)WindowFeatures.NoTitle);
            LayoutInflater inflate = LayoutInflater.From(mContext);
            View view = inflate.Inflate(Resource.Layout.dialog_confirm, null);
            mDialog.SetContentView(view);
            this.mYes = view.FindViewById

style样式


<resources>
  <style name="SystemAlertDialog" parent="android:Theme.Holo.Light.Dialog">
    <item name="android:windowBackground">@android:color/transparent
  style>
resources>

dialog_confirm

"1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="@dimen/dialog_w"
    android:layout_height="@dimen/dialog_h"
    android:background="@drawable/dialog_bg"
    android:minWidth="25px"
    android:minHeight="25px">
    "标题"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/dialog_title_mt"
        android:textSize="@dimen/dialog_title_font"
        android:textColor="@android:color/white"
        android:paddingBottom="@dimen/dialog_title_mb"
        android:gravity="center"
        android:id="@+id/tvTitle" />
    "horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:id="@+id/linearLayout1">
        

界面中使用

var msg = new SystemAlertDialogManager(this);
            msg.ShowRecordingDialog("是否删除数据", "确定", "取消");
            msg.YesClicked += new EventHandler((a, b) =>
            {
                msg.CloseDialog();
                //这里点击确定以后要执行的操作
            });
            msg.NoClicked += new EventHandler<EventArgs>((a, b) =>
            {
                msg.CloseDialog();
            });

你可能感兴趣的:(Mono,For,android)