本文整理汇总了C#中Android.App.AlertDialog.Builder.SetOnDismissListener方法的典型用法代码示例。如果您正苦于以下问题:C# AlertDialog.Builder.SetOnDismissListener方法的具体用法?C# AlertDialog.Builder.SetOnDismissListener怎么用?C# AlertDialog.Builder.SetOnDismissListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.AlertDialog.Builder
的用法示例。
在下文中一共展示了AlertDialog.Builder.SetOnDismissListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//as we expect this to happen only rarely (having a foreground service running when unlocked),
//we don't try to handle this better
//But at least explain to the user what happened!
((NotificationManager)GetSystemService(Context.NotificationService)).CancelAll();
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.SetMessage(Resource.String.killed_by_os);
b.SetPositiveButton(Android.Resource.String.Ok, delegate
{
Intent i = new Intent(this, typeof(FileSelectActivity));
i.AddFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);
StartActivity(i);
});
b.SetNegativeButton(Resource.String.cancel, delegate { });
b.SetTitle(GetString(AppNames.AppNameResource));
b.SetOnDismissListener(this);
var dialog = b.Create();
dialog.Show();
}
示例2: CreateDialog
private static AlertDialogInfo CreateDialog(
string content,
string title,
string okText = null,
string cancelText = null,
Action<bool> afterHideCallbackWithResponse = null)
{
var tcs = new TaskCompletionSource<bool>();
var builder = new AlertDialog.Builder(ActivityBase.CurrentActivity);
builder.SetMessage(content);
builder.SetTitle(title);
AlertDialog dialog = null;
builder.SetPositiveButton(okText ?? "OK", (d, index) =>
{
tcs.TrySetResult(true);
// ReSharper disable AccessToModifiedClosure
if (dialog != null)
{
dialog.Dismiss();
dialog.Dispose();
}
if (afterHideCallbackWithResponse != null)
{
afterHideCallbackWithResponse(true);
}
// ReSharper restore AccessToModifiedClosure
});
if (cancelText != null)
{
builder.SetNegativeButton(cancelText, (d, index) =>
{
tcs.TrySetResult(false);
// ReSharper disable AccessToModifiedClosure
if (dialog != null)
{
dialog.Dismiss();
dialog.Dispose();
}
if (afterHideCallbackWithResponse != null)
{
afterHideCallbackWithResponse(false);
}
// ReSharper restore AccessToModifiedClosure
});
}
builder.SetOnDismissListener(new OnDismissListener(() =>
{
tcs.TrySetResult(false);
if (afterHideCallbackWithResponse != null)
{
afterHideCallbackWithResponse(false);
}
}));
dialog = builder.Create();
return new AlertDialogInfo
{
Dialog = dialog,
Tcs = tcs
};
}