SetPositiveButton

时间:2016-12-14 20:03:22

标签: android xamarin alertdialog

我们有:

alertadd.SetPositiveButton("To Close", (senderAlert, args) =>
{
Toast.MakeText(this, "Closed", ToastLength.Short).Show();
});

我们可以为SetPositiveButton设置图像吗?我们已经关闭了#34; for SetPositiveButton。

1 个答案:

答案 0 :(得分:0)

您可以将自己的视图附加到对话框,并根据需要设置按钮的样式。例如:

var view = LayoutInflater.Inflate(Resource.Layout.dialog_layout, null);
var buttonYes = view.FindViewById<Button>(Resource.Id.yesButton);
var buttonNo = view.FindViewById<Button>(Resource.Id.noButton);
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
            dialogBuilder.SetView(view);
            var ad = dialogBuilder.Create();
            ad.Show();