xamarin.android 自定义AlertDialog
//AlertDialog中添加listview
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(view.Context).Create();
View vieDialog = LayoutInflater.From(view.Context).Inflate(Resource.Layout.dialoge_lv, null);
alertDialog.SetView(vieDialog);
adapter = new FgAdapter(alertDialog.Context);
ListView lv = vieDialog.FindViewById<ListView>(Resource.Id.lvDialog);
adapter.addData("1");
adapter.addData("2");
alertDialog.SetTitle(strTitle);
//BUTTON_POSITIVE -1
alertDialog.SetButton(-1, "确认", (sender, e) =>
{
Toast.MakeText(view.Context, "提醒!将关闭了哦,亲!", ToastLength.Short).Show();
});
alertDialog.Show()
//关闭alertDialog
alertDialog.Dismiss();
//--------AlertDialog ---------------------
AlertDialog.Builder alert = new AlertDialog.Builder(View.Context);
alert.SetTitle("Exception");
alert.SetMessage("Error:"+ex.Message);
alert.SetPositiveButton("确认",(sender,e)=> {
});
alert.Show();
由于xamarin中相对android中来说,有些区别,故记之以备忘。