本文整理汇总了C#中Android.App.AlertDialog.Builder.SetButton方法的典型用法代码示例。如果您正苦于以下问题:C# AlertDialog.Builder.SetButton方法的具体用法?C# AlertDialog.Builder.SetButton怎么用?C# AlertDialog.Builder.SetButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.AlertDialog.Builder
的用法示例。
在下文中一共展示了AlertDialog.Builder.SetButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowError
private void ShowError(string message)
{
var activity = this.GetService<IMvxAndroidCurrentTopActivity>().Activity as IMvxBindingActivity;
var alertDialog = new AlertDialog.Builder((Activity)activity).Create();
alertDialog.SetTitle("Sorry!");
alertDialog.SetMessage(message);
alertDialog.SetButton("OK", (sender, args) => {});
alertDialog.Show();
}
示例2: 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();
});
}
示例3: 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();
}
示例4: ShowError
private void ShowError(ErrorMessage message)
{
var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity as IMvxBindingContextOwner;
if (activity == null)
{
return;
}
var alertDialog = new AlertDialog.Builder((Activity)activity).Create();
alertDialog.SetTitle("Sorry!");
alertDialog.SetMessage(message.Message);
alertDialog.SetButton("OK", (sender, args) => {});
alertDialog.Show();
}
示例5: ShowAlertAsync
public Task ShowAlertAsync(string title, string message)
{
var tcs = new TaskCompletionSource<bool> ();
var alert = new AlertDialog.Builder(Forms.Context).Create();
alert.SetTitle(title);
alert.SetMessage(message);
alert.SetButton("OK", (sender, e) => {
tcs.TrySetResult(true);
});
alert.Show ();
return tcs.Task;
}
示例6: ConnectToServer
void ConnectToServer()
{
AlertDialog ad = null;
try
{
Sockets.client = new TcpClient(SERVER_IP, PORT);
}
catch (SocketException e)
{
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Nie można połączyć się z serwerem. Sprawdź połączenie z internetem.");
ad.SetButton("OK", delegate
{
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
});
ad.Show();
}
}
示例7: ShowAlertDialog
public static void ShowAlertDialog(Context context, string title, string message,
bool isSuccessStatus)
{
var alertDialog = new AlertDialog.Builder(context).Create();
// Setting Dialog Title
alertDialog.SetTitle(title);
// Setting Dialog Message
alertDialog.SetMessage(message);
// Setting alert dialog icon
alertDialog.SetIcon(isSuccessStatus ? Resource.Drawable.success : Resource.Drawable.fail);
// Setting OK Button
alertDialog.SetButton("OK", (sender, args) => { });
// Showing Alert Message
alertDialog.Show();
}
示例8: Delegat
void Delegat()
{
Intent intent = null;
EditText edittext = FindViewById<EditText>(Resource.Id.loginArea);
byte[] buffer = new byte[MAX_LENGTH];
AlertDialog ad = null;
buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Hello), edittext.Text));
Sockets.client.GetStream().Write(buffer, 0, buffer.Length);
buffer = new byte[MAX_LENGTH];
Sockets.client.GetStream().Read(buffer, 0, buffer.Length);
string[] parse = MessageParser.Split(buffer);
switch (MessageParser.ToMessageType(parse[0]))
{
case MessageTypes.WelcomeClient:
intent = new Intent(this, typeof(GameManager));
intent.PutExtra("Nickname", edittext.Text);
//strbuff = System.Text.Encoding.ASCII.GetString(buffer).Split(';')[1];
intent.PutExtra("PlayerList", parse[1]);
StartActivity(intent);
break;
case MessageTypes.PlayerExist:
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Gracz o takim nicku istnieje! Wpisz inny login");
ad.SetButton("OK", delegate {
Sockets.client.Close();
ConnectToServer();
});
ad.Show();
break;
default:
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Nieoczekiwany błąd. Aplikacja zostanie zamknięta.");
ad.SetButton("OK", delegate {
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
});
ad.Show();
break;
}
}
示例9: 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 ();
}
}
示例10: InternalSetPage
void InternalSetPage(Page page)
{
if (!Forms.IsInitialized)
throw new InvalidOperationException("Call Forms.Init (Activity, Bundle) before this");
if (_canvas != null)
{
_canvas.SetPage(page);
return;
}
var busyCount = 0;
MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
{
busyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1);
if (!Forms.SupportsProgress)
return;
SetProgressBarIndeterminate(true);
UpdateProgressBarVisibility(busyCount > 0);
});
UpdateProgressBarVisibility(busyCount > 0);
MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>
{
AlertDialog alert = new AlertDialog.Builder(this).Create();
alert.SetTitle(arguments.Title);
alert.SetMessage(arguments.Message);
if (arguments.Accept != null)
alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true));
alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false));
alert.CancelEvent += (o, args) => { arguments.SetResult(false); };
alert.Show();
});
MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) =>
{
var builder = new AlertDialog.Builder(this);
builder.SetTitle(arguments.Title);
string[] items = arguments.Buttons.ToArray();
builder.SetItems(items, (sender2, args) => { arguments.Result.TrySetResult(items[args.Which]); });
if (arguments.Cancel != null)
builder.SetPositiveButton(arguments.Cancel, delegate { arguments.Result.TrySetResult(arguments.Cancel); });
if (arguments.Destruction != null)
builder.SetNegativeButton(arguments.Destruction, delegate { arguments.Result.TrySetResult(arguments.Destruction); });
AlertDialog dialog = builder.Create();
builder.Dispose();
//to match current functionality of renderer we set cancelable on outside
//and return null
dialog.SetCanceledOnTouchOutside(true);
dialog.CancelEvent += (sender3, e) => { arguments.SetResult(null); };
dialog.Show();
});
_canvas = new Platform(this);
if (_application != null)
_application.Platform = _canvas;
_canvas.SetPage(page);
_layout.AddView(_canvas.GetViewGroup());
}
示例11: OnBackPressed
public override void OnBackPressed()
{
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Czy chcesz opuœciæ grê (oddasz walkowerem)?");
ad.SetButton("Nie", delegate { dialogLive = false; });
ad.SetButton2("Tak", delegate
{
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Left), nickname));
Sockets.client.GetStream().Write(buffer, 0, buffer.Length);
dialogLive = false;
});
dialogLive = true;
ad.Show();
}
示例12: GameThreadProc
void GameThreadProc()
{
NetworkStream stream = Sockets.client.GetStream();
byte[] buffer;
AlertDialog ad = null;
while (Sockets.client.Connected)
{
try
{
buffer = new byte[MainActivity.MAX_LENGTH];
stream.Read(buffer, 0, buffer.Length);
string[] data = MessageParser.Split(buffer);
if (data.Length == 1)
{
Sockets.client.Close();
RunOnUiThread(delegate
{
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
ad.SetButton("OK", delegate
{
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
});
ad.Show();
});
}
switch (MessageParser.ToMessageType(data[0]))
{
case MessageTypes.TurnClient:
RunOnUiThread(delegate { ParseCanvas(data[1]); });
isMyTurn = true;
break;
case MessageTypes.WinClient:
RunOnUiThread(delegate
{
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
if (data[1].Contains(nickname))
ad.SetMessage("Gratulacje! Wygra³eœ!");
else
ad.SetMessage("Niestety przegra³eœ!");
ad.SetButton("WyjdŸ", delegate
{
GameManager.thLock = false;
Finish();
});
ad.Show();
});
return;
break;
case MessageTypes.LeftClient:
RunOnUiThread(delegate
{
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Twój przeciwnik opuœci³ grê!");
ad.SetButton("WyjdŸ", delegate
{
//th.Abort();
GameManager.thLock = false;
Finish();
});
ad.Show();
});
return;
break;
}
}
catch (System.Threading.ThreadAbortException e)
{
return;
}
catch (Exception e)
{
Sockets.client.Close();
RunOnUiThread(delegate
{
ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
ad.SetButton("OK", delegate
{
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
});
ad.Show();
});
}
}
}
示例13: EnableWriteMode
private void EnableWriteMode()
{
_inWriteMode = true;
// Create an intent filter for when an NFC tag is discovered. When
// the NFC tag is discovered, Android will u
var tagDetected = new IntentFilter(NfcAdapter.ActionTagDiscovered);
var filters = new[] { tagDetected };
// When an NFC tag is detected, Android will use the PendingIntent to come back to this activity.
// The OnNewIntent method will invoked by Android.
var intent = new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop);
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0);
if (_nfcAdapter == null) {
var alert = new AlertDialog.Builder (this).Create ();
alert.SetMessage ("NFC is not supported on this device.");
alert.SetTitle ("NFC Unavailable");
alert.SetButton ("OK", delegate {
_button.Enabled = false;
_alertMessage.Text = "NFC is not supported on this device.";
});
alert.Show ();
} else
_nfcAdapter.EnableForegroundDispatch(this, pendingIntent, filters, null);
}
示例14: OnStartClicked
protected void OnStartClicked(object sender, EventArgs e){
if(tunnel.IsRunning){
ProgressDialog progress = null;
RunOnUiThread(delegate() {
progress = ProgressDialog.Show(this,"Disconnecting From Brick...","Closing connection... ");
});
System.Threading.Thread t = new System.Threading.Thread( delegate(object obj){
tunnel.Stop();
RunOnUiThread(delegate() {
progress.Dismiss();
ShowToast("Tunnel stoped");
});
});
t.IsBackground = true;
t.Priority = System.Threading.ThreadPriority.Normal;
t.Start();
}
else{
ProgressDialog progress = null;
System.Threading.Thread t = new System.Threading.Thread(delegate(object obj){
UpdateSettings();
if(bluetoothDeviceName == ""){
RunOnUiThread(delegate() {
AlertDialog dialog = new AlertDialog.Builder(this).Create();
dialog.SetTitle("Select Bluetooth Device");
dialog.SetMessage("No Bluetooth Device has been selected. Please go to settings and select a Bluetooth device");
dialog.SetButton("OK", delegate(object sen, DialogClickEventArgs eventArgs) {
});
dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
dialog.Show();
});
return;
}
RunOnUiThread(delegate() {
progress = ProgressDialog.Show(this,"Connecting To Brick...","Opening connection... ",true,false);
});
connection = new MonoBrick.Bluetooth<MonoBrick.NXT.Command, MonoBrick.NXT.Reply>(bluetoothDeviceName);
//connection = new Loopback();
if(tunnel.Start(tunnelSettings, connection)){
RunOnUiThread(delegate() {
progress.Dismiss();
ShowToast("Tunnel started");
});
}
else{
RunOnUiThread(delegate() {
progress.Dismiss();
ShowToast("Failed to start tunnel");
});
}
});
t.IsBackground = true;
t.Priority = System.Threading.ThreadPriority.Normal;
t.Start();
}
}
示例15: ButtonClickEvent
private void ButtonClickEvent(int numerek)
{
if (isMyTurn)
{
if (canvas[numerek] != '-')
{
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Te pole jest ju¿ zajête!");
ad.SetButton("OK", delegate { });
ad.Show();
return;
}
canvas[numerek] = mySign;
byte[] buffbuff = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Turn), new string(canvas)));
pole[numerek].Text = Char.ToString(mySign);
Sockets.client.GetStream().Write(buffbuff, 0, buffbuff.Length);
isMyTurn = false;
}
else
{
AlertDialog ad = new AlertDialog.Builder(this).Create();
ad.SetCancelable(false); // This blocks the 'BACK' button
ad.SetMessage("Poczekaj na swoj¹ kolej!");
ad.SetButton("OK", delegate {});
ad.Show();
}
}