本文整理汇总了C#中Android.App.AlertDialog.Builder.SetNeutralButton方法的典型用法代码示例。如果您正苦于以下问题:C# AlertDialog.Builder.SetNeutralButton方法的具体用法?C# AlertDialog.Builder.SetNeutralButton怎么用?C# AlertDialog.Builder.SetNeutralButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.AlertDialog.Builder
的用法示例。
在下文中一共展示了AlertDialog.Builder.SetNeutralButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainApp
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
// Catch unhandled exceptions
// Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html
// Add an exception handler for all uncaught exceptions.
AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler;
AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler;
// Save prefernces instance
Main.Prefs = new PreferenceValues(PreferenceManager.GetDefaultSharedPreferences(this));
// Get path from preferences or default path
string path = Main.Prefs.GetString("filepath", Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "WF.Player"));
try {
if (!Directory.Exists (path))
Directory.CreateDirectory (path);
}
catch {
}
if (!Directory.Exists (path))
{
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.SetTitle (GetString (Resource.String.main_error));
builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path));
builder.SetCancelable (true);
builder.SetNeutralButton(Resource.String.ok,(obj,arg) => { });
builder.Show ();
} else {
Main.Path = path;
Main.Prefs.SetString("filepath", path);
}
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
RequestedOrientation = global::Android.Content.PM.ScreenOrientation.Landscape;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
SignaturePadView signature = FindViewById<SignaturePadView> (Resource.Id.signatureView);
// Get our button from the layout resource,
// and attach an event to it
Button btnSave = FindViewById<Button> (Resource.Id.btnSave);
btnSave.Click += delegate {
if (signature.IsBlank)
{//Display the base line for the user to sign on.
AlertDialog.Builder alert = new AlertDialog.Builder (this);
alert.SetMessage ("No signature to save.");
alert.SetNeutralButton ("Okay", delegate { });
alert.Create ().Show ();
}
points = signature.Points;
};
btnSave.Dispose ();
Button btnLoad = FindViewById<Button> (Resource.Id.btnLoad);
btnLoad.Click += delegate {
if (points != null)
signature.LoadPoints (points);
};
btnLoad.Dispose ();
}
示例3: Display
public bool Display (string body, string cancelButtonTitle, string acceptButtonTitle = "", Action action = null, bool negativeAction = false)
{
AlertDialog.Builder alert = new AlertDialog.Builder (Forms.Context);
alert.SetTitle ("Alert");
alert.SetMessage (body);
alert.SetNeutralButton (cancelButtonTitle, (senderAlert, args) => {
});
if (acceptButtonTitle != "") {
if (!negativeAction) {
alert.SetPositiveButton (acceptButtonTitle, (senderAlert, args) => {
if (action != null) {
action.Invoke ();
}
});
} else {
alert.SetNegativeButton (acceptButtonTitle, (senderAlert, args) => {
if (action != null) {
action.Invoke ();
}
});
}
}
((Activity)Forms.Context).RunOnUiThread (() => {
alert.Show ();
});
return true;
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
button = FindViewById<Button> (Resource.Id.button);
button.Click += (o, e) => {
// use an array adapter to populate a spinner item from our string array
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
Android.Resource.Layout.SimpleSpinnerItem, villains);
// create the spinner and populate it with our items
Spinner spinner = new Spinner(this);
spinner.LayoutParameters = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
spinner.Adapter = adapter;
// handle item selection
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (ItemSelected);
// build the alert dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetView(spinner);
builder.SetNeutralButton("OK", delegate {});
builder.Show();
};
}
示例5: Display
public void Display (string body, string title, GoalsAvailable availableGoal, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
{
EditText goalTextBox = new EditText (Forms.Context);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Forms.Context);
alertDialogBuilder.SetTitle (title);
alertDialogBuilder.SetMessage (body);
alertDialogBuilder.SetView (goalTextBox);
goalTextBox.InputType = Android.Text.InputTypes.NumberFlagSigned;
var inputFilter = new Android.Text.InputFilterLengthFilter (7);
var filters = new Android.Text.IInputFilter[1];
filters [0] = inputFilter;
goalTextBox.SetFilters (filters);
goalTextBox.InputType = Android.Text.InputTypes.ClassNumber;
alertDialogBuilder.SetPositiveButton ("OK", (senderAlert, args) => {
if(action != null)
{
int goalValue;
int.TryParse(goalTextBox.Text, out goalValue);
action.Invoke(availableGoal, goalValue);
}
} );
alertDialogBuilder.SetNeutralButton ("CANCEL", (senderAlert, args) => {
} );
alertDialogBuilder.Show ();
}
示例6: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
FindViewById<EditText>(Resource.Id.modemPassword).RequestFocus();
FindViewById<Button>(Resource.Id.next).Click += (s,e) => {
if(ModemPassword=="")
{
var diag=new AlertDialog.Builder(this);
diag.SetTitle("Device Access Code Required!");
diag.SetMessage("A password or Device Access Code is required! It is usually a 10-digit number printed on your modem");
diag.SetIcon(Android.Resource.Drawable.IcDialogAlert);
diag.SetNeutralButton("Ok", new EventHandler<DialogClickEventArgs>((s2, e2) => {} ));
diag.Show();
return;
}
var controller = new Intent(this, typeof(ControllerActivity));
controller.PutExtra("address", ModemAddress);
controller.PutExtra("password", ModemPassword);
StartActivity(controller);
};
// Get our button from the layout resource,
// and attach an event to it
//must get address and password in this context because it can change later, but other threads can't access it
}
示例7: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
Button callHistoryButton = FindViewById<Button>(Resource.Id.CallHistoryButton);
// "Call" を Disable にします
callButton.Enabled = false;
// 番号を変換するコードを追加します。
string translatedNumber = string.Empty;
translateButton.Click += (object sender, EventArgs e) =>
{
// ユーザーのアルファベットの電話番号を電話番号に変換します。
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber))
{
callButton.Text = "Call";
callButton.Enabled = false;
}
else
{
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) =>
{
// "Call" ボタンがクリックされたら電話番号へのダイヤルを試みます。
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate
{
// 掛けた番号のリストに番号を追加します。
phoneNumbers.Add(translatedNumber);
// Call History ボタンを有効にします。
callHistoryButton.Enabled = true;
// 電話への intent を作成します。
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
// アラートダイアログを表示し、ユーザーのレスポンスを待ちます。
callDialog.Show();
};
callHistoryButton.Click += (sender, e) =>
{
var intent = new Intent(this, typeof(CallHistoryActivity));
intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
StartActivity(intent);
};
}
示例8: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource.
SetContentView (Resource.Layout.Main);
// Get our UI controls from the loaded layout:
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
Button callHistoryButton = FindViewById<Button> (Resource.Id.CallHistoryButton);
// Disable the "Call" button.
callButton.Enabled = false;
// Add code to translate number.
string translatedNumber = string.Empty;
translateButton.Click += (object sender, EventArgs e) => {
// Translate user's alphanumeric phone number to numeric.
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber)) {
callButton.Text = "Call";
callButton.Enabled = false;
} else {
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) => {
// On "Call" button click, try to dial phone number.
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate {
// Add dialed number to list of called numbers.
phoneNumbers.Add(translatedNumber);
// Enable the Call History button.
callHistoryButton.Enabled = true;
// Create intent to dial phone.
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate {});
// Show the alert dialog to the user and wait for response.
callDialog.Show();
};
callHistoryButton.Click += (sender, e) => {
var intent = new Intent(this, typeof(CallHistoryActivity));
intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
StartActivity(intent);
};
}
示例9: OnStart
protected override void OnStart ()
{
base.OnStart ();
InitService ();
var button1 = FindViewById<Button> (Resource.Id.buttonCalc);
button1.Click += (sender, e) => {
if (IsBound) {
var text1 = FindViewById<EditText> (Resource.Id.value1);
var text2 = FindViewById<EditText> (Resource.Id.value2);
var result = FindViewById<TextView> (Resource.Id.result);
int v1;
int v2;
int v3;
if(Int32.TryParse (text2.Text, out v2) && Int32.TryParse (text1.Text, out v1)) {
v3 = Service.Add (v1, v2);
} else {
v3 = 0;
var builder = new AlertDialog.Builder(this);
builder.SetMessage("Spaces or special character are not allowed");
builder.SetNeutralButton("OK", (source, eventArgs) => {});
builder.Show();
}
result.Text = v3.ToString ();
} else {
Log.Warn (Tag, "The AdditionService is not bound");
}
};
}
示例10: CreateAndShowDialog
void CreateAndShowDialog(string message, string title)
{
var builder = new AlertDialog.Builder(Forms.Context);
builder.SetMessage(message);
builder.SetTitle(title);
builder.SetNeutralButton("OK", (sender, args) => { });
builder.Create().Show();
}
示例11: CreateExceptionDialog
private void CreateExceptionDialog()
{
var alert = new AlertDialog.Builder(this);
alert.SetTitle("Network Error");
alert.SetMessage("Could not contact the server - please try again later.");
alert.SetNeutralButton("OK", (senderAlert, args) => { });
alert.Show();
}
示例12: alertDebug
public void alertDebug(String msg)
{
// Alert user to that an invalid phoneword was entered
var myAlert = new AlertDialog.Builder(this);
myAlert.SetMessage(msg);
myAlert.SetNeutralButton("Ok", delegate { });
myAlert.SetNegativeButton("Cancel", delegate { });
myAlert.Show();
}
示例13: OnItemClick
void OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
var marker = MarkerData.Markers[e.Position];
var dialog = new AlertDialog.Builder(this);
dialog.SetMessage(marker.Title);
dialog.SetNeutralButton("OK", delegate { });
dialog.Show();
}
示例14: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
Button callHistoryButton = FindViewById<Button>(Resource.Id.CallHistoryButton);
callButton.Enabled = false;
string translatedNumber = string.Empty;
translateButton.Click += (object sender, EventArgs e) =>
{
translatedNumber = Phoneword.PhoneTranslator.ToNumber(phoneNumberText.Text);
if (string.IsNullOrWhiteSpace(translatedNumber))
{
callButton.Text = "Call";
callButton.Enabled = false;
}
else
{
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) =>
{
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate
{
//Ajoute le numéro à la liste des numéros appelés
phoneNumbers.Add(translatedNumber);
//Active le bouton
callHistoryButton.Enabled = true;
//Crée un Intent pour lancer un appel
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
callDialog.Show();
};
callHistoryButton.Click += (object sender, EventArgs e) =>
{
var intent = new Intent(this, typeof(CallHistoryActivity));
intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
StartActivity(intent);
};
}
示例15: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
EditText txtPhoneNumber = FindViewById<EditText>(Resource.Id.txtPhoneNumber);
Button btnTranslate = FindViewById<Button>(Resource.Id.btnTranslate);
Button btnCall = FindViewById<Button>(Resource.Id.btnCall);
Button btnGetLocation = FindViewById<Button>(Resource.Id.btnLocation);
btnCall.Enabled = false;
string translatedNumber = string.Empty;
btnTranslate.Click += (object o, EventArgs e)=> {
translatedNumber = PhoneTranslator.ToNumber(txtPhoneNumber.Text);
if (string.IsNullOrWhiteSpace(translatedNumber))
{
btnCall.Text = "Call";
btnCall.Enabled = false;
}
else
{
btnCall.Text = string.Format("Call {0}", translatedNumber);
btnCall.Enabled = true;
}
};
btnCall.Click += (object o, EventArgs e) => {
//初始化对话框
var callDialog = new AlertDialog.Builder(this);
//对话框内容
callDialog.SetMessage(string.Format("Call {0}?", translatedNumber));
callDialog.SetNeutralButton("Call", delegate {
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
callDialog.Show();
};
btnGetLocation.Click += (o, e) => {
// Get Location
LocationManager lm = (LocationManager)GetSystemService(LocationService);
var tent = new Intent(this, typeof(LocationBroadCast));
var ptent = PendingIntent.GetBroadcast(this, 0, tent, PendingIntentFlags.UpdateCurrent);
lm.RequestLocationUpdates(GetBestLocationProvider(lm), 5000, 100, ptent);
};
}