安卓自定义AlertDialog弹出框
来源:互联网 发布:中国航空发动机 知乎 编辑:程序博客网 时间:2024/05/30 23:04
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<Button>(Resource.Id.btnSure); this.mNo = view.FindViewById<Button>(Resource.Id.btnCancel); this.tvTitle = view.FindViewById<TextView>(Resource.Id.tvTitle); tvTitle.Text = remind; mYes.Text = yes; mNo.Text = no; mYes.Click += mYes_Click; mNo.Click += mNo_Click; mDialog.Show(); } void mNo_Click(object sender, EventArgs e) { if (NoClicked != null) { NoClicked(mContext, e); } } void mYes_Click(object sender, EventArgs e) { if (YesClicked != null) { YesClicked(mContext, e); } } public void CloseDialog() { this.mDialog.Dismiss(); this.mDialog.Dispose(); this.mDialog = null; } public event EventHandler<EventArgs> YesClicked; public event EventHandler<EventArgs> NoClicked; }
style样式
<?xml version="1.0" encoding="utf-8" ?><resources> <style name="SystemAlertDialog" parent="android:Theme.Holo.Light.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> </style></resources>
dialog_confirm
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="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"> <TextView android:text="标题" 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" /> <LinearLayout android:orientation="horizontal" android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/linearLayout1"> <Button android:text="确定" android:layout_width="@dimen/dialog_btn_w" android:layout_height="wrap_content" android:textSize="@dimen/dialog_button_font" android:textColor="@drawable/dialog_btn_selector" android:paddingTop="@dimen/dialog_button_ptb" android:paddingBottom="@dimen/dialog_button_ptb" android:gravity="center" android:background="@android:color/transparent" android:id="@+id/btnSure" /> <Button android:text="取消" android:layout_width="@dimen/dialog_btn_w" android:layout_height="wrap_content" android:background="@android:color/transparent" android:textSize="@dimen/dialog_button_font" android:textColor="@drawable/dialog_btn_selector" android:paddingTop="@dimen/dialog_button_ptb" android:paddingBottom="@dimen/dialog_button_ptb" android:gravity="center" android:id="@+id/btnCancel" /> </LinearLayout></LinearLayout>
界面中使用
var msg = new SystemAlertDialogManager(this); msg.ShowRecordingDialog("是否删除数据", "确定", "取消"); msg.YesClicked += new EventHandler<EventArgs>((a, b) => { msg.CloseDialog(); //这里点击确定以后要执行的操作 }); msg.NoClicked += new EventHandler<EventArgs>((a, b) => { msg.CloseDialog(); });
阅读全文
0 0
- 安卓自定义AlertDialog弹出框
- 自定义弹出AlertDialog弹出框
- android 自定义弹出框AlertDialog
- android 自定义弹出框AlertDialog
- Android自定义弹出框AlertDialog
- 安卓弹出对话框——Alertdialog
- (安卓) AlertDialog 弹出对话框效果
- Android使用自定义弹出框AlertDialog
- 自定义AlertDialog,模仿Ios弹出框
- 自定义弹出窗口AlertDialog
- AlertDialog自定义弹出对话框
- 安卓自定义对话框(基于AlertDialog)
- 安卓AlertDialog自定义显示内容
- 安卓开发:AlertDialog类的使用【弹出对话框、进度条、输入框、单选框、复选框】
- 安卓弹出对话框——Alertdialog(一)
- 安卓弹出对话框——Alertdialog(一)
- 安卓弹出对话框——Alertdialog(一)
- android 自定义弹出框AlertDialog ,很炫的哦
- JVM垃圾回收算法和内存分配策略
- 求数组中和为给定值的所有子序列
- JAVA开发环境的搭建(配置JAVA开发环境)
- 基于京东云服务器来搭建javaWeb 运行环境
- 1134. Vertex Cover (25)-PAT甲级真题
- 安卓自定义AlertDialog弹出框
- django中render()与render_to_response()区别
- socket服务器开发中的SO_REUSEADDR选项与让人心烦的TIME_WAIT
- 1135. Is It A Red-Black Tree (30)-PAT甲级真题
- bzoj2095 Bridges
- mysql update 多表
- css pointer-events属性
- httpClient工具类
- 编程中的幂等性 —— HTTP幂等性