本文整理汇总了C#中Android.App.AlertDialog.Builder.Dismiss方法的典型用法代码示例。如果您正苦于以下问题:C# AlertDialog.Builder.Dismiss方法的具体用法?C# AlertDialog.Builder.Dismiss怎么用?C# AlertDialog.Builder.Dismiss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.AlertDialog.Builder
的用法示例。
在下文中一共展示了AlertDialog.Builder.Dismiss方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowErrorDialog
protected void ShowErrorDialog(Exception ex)
{
RunOnUiThread(() =>
{
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false);
ad.SetMessage(string.Format("An error has occured: {0}", ex));
ad.SetButton("OK", (sender, args) => ad.Dismiss());
ad.Show();
});
}
示例2: ShowMsgBox_OK
public static void ShowMsgBox_OK(Activity currentActivity, string title, string msg)
{
AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).Create();
alertDialog.SetTitle(title);
alertDialog.SetMessage(msg);
alertDialog.SetButton((int)DialogButtonType.Neutral, "OK",
(object sender, DialogClickEventArgs e) => {
alertDialog.Dismiss();
});
alertDialog.Show();
}
示例3: RenderResults
private void RenderResults(List<Product> products)
{
if (products == null || products.Count == 0)
{
_progressDialog.Dismiss ();
var alertDialog = new AlertDialog.Builder(this).Create();
alertDialog.SetTitle("Search Results");
alertDialog.SetMessage("We were unable to find any matches in the catalog.");
alertDialog.SetIcon(Resource.Drawable.icon);
alertDialog.SetButton("OK", (o, e) =>
{
alertDialog.Dismiss();
Finish();
});
alertDialog.Show();
}
else
{
SetContentView (Resource.Layout.SearchResults);
ListView.SetBackgroundColor (G.Color.Transparent);
ListAdapter = new ProductListAdapter(this, products);
_progressDialog.Dismiss ();
}
}
示例4: SyncCompleted
public void SyncCompleted()
{
RunOnUiThread(() => {
_lblTitle.Text = "Sync completed";
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false);
ad.SetMessage("Sync has completed successfully.");
ad.SetButton("OK", (sender, args) => {
ad.Dismiss();
Finish();
});
ad.Show();
});
}
示例5: ShowMessage
public void ShowMessage(string title, string message)
{
RunOnUiThread(() => {
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false);
ad.SetTitle(title);
ad.SetMessage(message);
ad.SetButton("OK", (sender, args) => ad.Dismiss());
ad.Show();
});
}
示例6: SyncEmptyError
public void SyncEmptyError(Exception ex)
{
RunOnUiThread(() => {
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false);
ad.SetTitle("Error");
ad.SetMessage(ex.Message);
ad.SetButton("OK", (sender, args) => ad.Dismiss());
ad.Show();
});
}
示例7: PromptForInputAsync
public override void PromptForInputAsync(string prompt, bool startVoiceRecognizer, Action<string> callback)
{
new Thread(() =>
{
string input = null;
ManualResetEvent dialogDismissWait = new ManualResetEvent(false);
GetMainActivityAsync(true, mainActivity => mainActivity.RunOnUiThread(() =>
{
EditText inputEdit = new EditText(mainActivity);
AlertDialog dialog = new AlertDialog.Builder(mainActivity)
.SetTitle("Sensus is requesting input...")
.SetMessage(prompt)
.SetView(inputEdit)
.SetPositiveButton("OK", (o, e) =>
{
input = inputEdit.Text;
})
.SetNegativeButton("Cancel", (o, e) => { })
.Create();
// for some reason, stopping the activity with the home button doesn't raise the alert dialog's dismiss
// event. so, we'll manually trap the activity stop and dismiss the dialog ourselves. this is important
// because the caller of this method might be blocking itself or others (e.g., other prompts) until
// the dialog is dismissed. if we don't trap the activity stop then those blocks could go on indefinitely.
EventHandler activityStoppedHandler = (o,e) =>
{
dialog.Dismiss();
};
mainActivity.Stopped += activityStoppedHandler;
dialog.DismissEvent += (o,e) =>
{
// we don't need the dismiss event anymore, since the dialog has closed
mainActivity.Stopped -= activityStoppedHandler;
dialogDismissWait.Set();
};
ManualResetEvent dialogShowWait = new ManualResetEvent(false);
dialog.ShowEvent += (o,e) =>
{
dialogShowWait.Set();
};
// dismiss the keyguard when dialog appears
dialog.Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard);
dialog.Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked);
dialog.Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn);
dialog.Window.SetSoftInputMode(global::Android.Views.SoftInput.StateAlwaysVisible);
// dim whatever is behind the dialog
dialog.Window.AddFlags(global::Android.Views.WindowManagerFlags.DimBehind);
dialog.Window.Attributes.DimAmount = 0.75f;
dialog.Show();
#region voice recognizer
if (startVoiceRecognizer)
{
new Thread(() =>
{
// wait for the dialog to be shown so it doesn't hide our speech recognizer activity
dialogShowWait.WaitOne();
// there's a slight race condition between the dialog showing and speech recognition showing. pause here to prevent the dialog from hiding the speech recognizer.
Thread.Sleep(1000);
Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
intent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
intent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
intent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
intent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
intent.PutExtra(RecognizerIntent.ExtraPrompt, prompt);
mainActivity.GetActivityResultAsync(intent, AndroidActivityResultRequestCode.RecognizeSpeech, result =>
{
if (result != null && result.Item1 == Result.Ok)
{
IList<string> matches = result.Item2.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
if (matches != null && matches.Count > 0)
mainActivity.RunOnUiThread(() =>
{
inputEdit.Text = matches[0];
});
}
});
}).Start();
}
#endregion
}));
dialogDismissWait.WaitOne();
//.........这里部分代码省略.........