本文整理汇总了C#中Android.App.AlertDialog.Builder.SetPositiveButton方法的典型用法代码示例。如果您正苦于以下问题:C# AlertDialog.Builder.SetPositiveButton方法的具体用法?C# AlertDialog.Builder.SetPositiveButton怎么用?C# AlertDialog.Builder.SetPositiveButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.AlertDialog.Builder
的用法示例。
在下文中一共展示了AlertDialog.Builder.SetPositiveButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MsgBox
public static void MsgBox(Context context,
string msg,
string Titolo = "Vegetha",
string PositiveText = "OK",
Action PositiveAction = null,
string NegativeText ="",
Action NegativeAction = null)
{
AlertDialog.Builder d = new AlertDialog.Builder (context);
d.SetTitle(Titolo);
d.SetMessage (msg);
if (PositiveAction != null) {
d.SetPositiveButton (PositiveText, (sender, e) => {
PositiveAction.Invoke();
});
} else {
d.SetPositiveButton (PositiveText, (sender, e) => {
});
}
if (NegativeAction != null) {
d.SetNegativeButton (NegativeText, (sender, e) => {
NegativeAction.Invoke ();
});
}
d.Show ();
}
示例2: Alert
public static void Alert(Activity context, string title, string message, bool CancelButton, Action<Result> callback = null)
{
context.RunOnUiThread(() =>
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.SetTitle(title);
builder.SetMessage(message);
if (callback != null)
{
builder.SetPositiveButton("Ok", (sender, e) =>
{
callback(Result.Ok);
});
if (CancelButton)
{
builder.SetNegativeButton("Cancel", (sender, e) =>
{
callback(Result.Canceled);
});
}
}
else
{
builder.SetPositiveButton("OK", (sender, e) => { });
}
builder.Show();
});
}
示例3: AlertYesOrNo
public static void AlertYesOrNo(Activity context, string title, string message, Action<Result> callback)
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.SetTitle(title);
builder.SetMessage(message);
if (callback != null)
{
builder.SetPositiveButton("Yes", (sender, e) =>
{
callback(Result.Ok);
});
builder.SetNegativeButton("No", (sender, e) =>
{
callback(Result.Canceled);
});
}
else
{
builder.SetPositiveButton("OK", (sender, e) => { });
}
builder.Show();
}
示例4: ShowEula
/**
* Show End User License Agreement.
*
* @param accepted True IFF user has accepted license already, which means it can be dismissed.
* If the user hasn't accepted, then the EULA must be accepted or the program
* exits.
* @param activity Activity started from.
*/
public static void ShowEula(bool accepted, Activity activity)
{
AlertDialog.Builder eula = new AlertDialog.Builder(activity)
.SetTitle(Resource.String.eula_title)
.SetIcon(Android.Resource.Drawable.IcDialogInfo)
.SetMessage(Resource.String.eula_text)
.SetCancelable(accepted);
if (accepted)
{
eula.SetPositiveButton(Android.Resource.String.Ok, (object dialog, DialogClickEventArgs which) => {
(dialog as IDialogInterface).Dismiss();
});
} else {
eula.SetPositiveButton(Resource.String.accept,(object dialog, DialogClickEventArgs which) => {
SetAcceptedEula(activity);
(dialog as IDialogInterface).Dismiss();
})
.SetNegativeButton(Resource.String.decline, (object dialog, DialogClickEventArgs which) => {
(dialog as IDialogInterface).Cancel();
activity.Finish();
});
}
eula.Show();
}
示例5: GetInfo
void GetInfo()
{
// создаем xml-документ
XmlDocument xmlDocument = new XmlDocument ();
// делаем запрос на получение имени пользователя
WebRequest webRequest = WebRequest.Create ("https://api.vk.com/method/users.get.xml?&access_token=" + token);
WebResponse webResponse = webRequest.GetResponse ();
Stream stream = webResponse.GetResponseStream ();
xmlDocument.Load (stream);
string name = xmlDocument.SelectSingleNode ("response/user/first_name").InnerText;
// делаем запрос на проверку,
webRequest = WebRequest.Create ("https://api.vk.com/method/groups.isMember.xml?group_id=20629724&access_token=" + token);
webResponse = webRequest.GetResponse ();
stream = webResponse.GetResponseStream ();
xmlDocument.Load (stream);
bool habrvk = (xmlDocument.SelectSingleNode ("response").InnerText =="1");
// выводим диалоговое окно
var builder = new AlertDialog.Builder (this);
// пользователь состоит в группе "хабрахабр"?
if (!habrvk) {
builder.SetMessage ("Привет, "+name+"!\r\n\r\nТы не состоишь в группе habrahabr.Не хочешь вступить?");
builder.SetPositiveButton ("Да", (o, e) => {
// уточнив, что пользователь желает вступить, отправим запрос
webRequest = WebRequest.Create ("https://api.vk.com/method/groups.join.xml?group_id=20629724&access_token=" + token);
webResponse = webRequest.GetResponse ();
});
builder.SetNegativeButton ("Нет", (o, e) => {
});
} else {
builder.SetMessage ("Привет, "+name+"!\r\n\r\nОтлично! Ты состоишь в группе habrahabr.");
builder.SetPositiveButton ("Ок", (o, e) => {
});
}
builder.Create().Show();
}
示例6: ForgotPassword
public async void ForgotPassword(View view)
{
ProgressDialog dialog = DialogHelper.CreateProgressDialog("Please wait...", this);
dialog.Show();
EditText StudentId = FindViewById<EditText>(Resource.Id.forgotStudentId);
AuthService ForgotPasswordService = new AuthService();
GenericResponse Response = await ForgotPasswordService.ForgotPassword(StudentId.Text);
dialog.Hide();
if (Response.Success)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
builder.SetTitle("Password Reset Sent");
builder.SetMessage("Please check your emails to reset your password");
builder.SetCancelable(false);
builder.SetPositiveButton("OK", delegate { Finish(); });
builder.Show();
}
else
{
DialogHelper.ShowDialog(this, Response.Message, Response.Title);
}
}
示例7: OnResume
protected override async void OnResume()
{
base.OnResume ();
Title = DataHolder.Current.CurrentCity.Name;
// Load pollutions
pollutionService = new PollutionService(Settings.ApiBaseUrl);
var pollutions = await pollutionService.GetPollutionForCity(DataHolder.Current.CurrentCity.Zip);
if (pollutions == null)
{
// An error occured
var builder = new AlertDialog.Builder(this);
builder.SetTitle(GetString(Resource.String.error_header));
builder.SetMessage(GetString(Resource.String.pollution_error_body));
builder.SetPositiveButton (GetString (Android.Resource.String.Ok), (senderAlert, args) => {});
builder.Show();
} else {
DataHolder.Current.CurrentPollutions = pollutions;
}
// Initialize tabs
AddPollutionDayTab(Resources.GetString(Resource.String.tab_today), 0);
AddPollutionDayTab(Resources.GetString(Resource.String.tab_tomorrow), 1);
AddPollutionDayTab(Resources.GetString(Resource.String.tab_aftertomorrow), 2);
// Hide loading indicator
var loading = FindViewById<ProgressBar> (Resource.Id.pbLoading);
loading.Visibility = ViewStates.Gone;
}
示例8: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Splash);
new Handler ().PostDelayed (() => {
//LoadActivity();
var updateManager = new UpdateManager(this,true);
if (updateManager.CheckUpdate())
{
var builder = new AlertDialog.Builder (this).SetTitle ("软件升级").SetMessage ("发现新版本,建议更新使用新版本").SetOnKeyListener(this).SetCancelable(false);
builder.SetPositiveButton ("下载", (sender, e) => {
noticeDialog.Dismiss();
//显示下载对话框,下载
updateManager.ShowDownloadDialog();
});
builder.SetNegativeButton ("以后再说", (sender, e) => {
noticeDialog.Dismiss();
LoadActivity();
});
noticeDialog= builder.Create ();
noticeDialog.Show();
}
else
{
LoadActivity();
}
},2000);
// Create your application here
}
示例9: CreateChatRooms
protected void CreateChatRooms(){
chatroomsAdapter = new ChatRoomsAdapter (this);
var chatRoomsListView = FindViewById<ListView> (Resource.Id.chatroomsListView);
chatRoomsListView.Adapter = chatroomsAdapter;
chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
var intent = new Intent(this, typeof(ChatRoomActivity));
intent.PutExtra("chatroom", currChatRoom.webID);
StartActivity(intent);
};
chatRoomsListView.ItemLongClick += async (object sender, AdapterView.ItemLongClickEventArgs e) => {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.SetTitle("Do you want to delete this chatroom?");
alert.SetPositiveButton("Yes", (senderAlert, args) => {
ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
ParsePush.UnsubscribeAsync (currChatRoom.webID);
ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID);
DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID);
ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase();
pcrd.DeleteChatRoomUserAsync(cru);
Console.WriteLine("ERASED");
chatroomsAdapter.NotifyDataSetChanged();
});
alert.SetNegativeButton("No", (senderAlert, args) => {
});
alert.Show();
};
}
示例10: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
String extra = Intent.GetStringExtra("User") ?? "Data not available";
var builder = new AlertDialog.Builder(this);
builder.SetTitle("Logged in");
builder.SetMessage(extra);
builder.SetPositiveButton("Ok", delegate { Finish(); });
builder.Create().Show();
// Create your application here
SetContentView(Resource.Layout.Home);
TextView textView = FindViewById<TextView>(Resource.Id.textView_Username);
textView.Text = extra;
Button goToBogdan = FindViewById<Button>(Resource.Id.button_Veres);
Button goToMiki = FindViewById<Button>(Resource.Id.button_Miki);
goToBogdan.Click += (sender, args) =>
{
var bogdan = new Intent(this, typeof(Bogdan));
StartActivity(bogdan);
};
goToMiki.Click += (sender, args) =>
{
var miki = new Intent(this, typeof(Miki));
StartActivity(miki);
};
}
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.loginButton);
button.Click += delegate {
//set alert for executing the task
var alert = new AlertDialog.Builder (this);
alert.SetTitle ("Login Popup");
alert.SetPositiveButton ("OK", (senderAlert, args) => {
});
alert.SetMessage ("Logged In");
//run the alert in UI thread to display in the screen
RunOnUiThread (() => {
alert.Show ();
});
};
}
示例12: showConfirmDialog
public bool showConfirmDialog(Context context, string info)
{
if (!prepareModal())
return false;
// reset choice
mChoice = false;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.SetMessage(info);
builder.SetCancelable(false);
builder.SetPositiveButton("OK", (object o, Android.Content.DialogClickEventArgs e) =>
{
this.mQuitModal = true;
this.mChoice = true;
builder.Dispose();
});
builder.SetNegativeButton("Cancel", (object o, Android.Content.DialogClickEventArgs e) =>
{
mQuitModal = true;
mChoice = false;
builder.Dispose(); // probably wrong
});
AlertDialog alert = builder.Create();
alert.Show();
doModal();
return mChoice;
}
示例13: initListeners
private void initListeners()
{
create.Click += delegate
{
if(!validdateForm()) return;
create.Enabled = false;
var task = Task<TournamentModel>.Factory.StartNew(() => ServerData.createTournament(name.Text, Session.Instance().CurrentUser.Id));
task.ContinueWith(x =>
{
create.Enabled = true;
try
{
if (x.Exception != null) throw x.Exception.InnerException;
// Success
Session.Instance().selectedTournament = task.Result;
StartActivity(typeof(TournamentDetails));
Finish();
}
catch (WebException e)
{
var builder = new AlertDialog.Builder(this);
builder.SetMessage("Er is iets mis met de verbinding, probeer het later opnieuw.");
builder.SetCancelable(false);
builder.SetPositiveButton("OK", delegate { });
builder.Show();
}
},
TaskScheduler.FromCurrentSynchronizationContext());
};
}
示例14: Register
public async void Register(View view)
{
ProgressDialog dialog = DialogHelper.CreateProgressDialog("Registering...", this);
dialog.Show();
RegisterRequest request = new RegisterRequest
{
FirstName = FindViewById<EditText>(Resource.Id.registerFirstName).Text,
LastName = FindViewById<EditText>(Resource.Id.registerLastName).Text,
StudentId = FindViewById<EditText>(Resource.Id.registerStudentId).Text,
Password = FindViewById<EditText>(Resource.Id.registerPassword).Text
};
GenericResponse Response = await Services.Auth.Register(request);
dialog.Hide();
if (Response.Success)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
builder.SetTitle("Successfully Registered");
builder.SetMessage("Please check your UTS email for instructions to confirm your account");
builder.SetCancelable(false);
builder.SetPositiveButton("OK", delegate { Finish(); });
builder.Show();
}
else
{
DialogHelper.ShowDialog(this, Response.Message, Response.Title);
}
}
示例15: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
#if __ANDROID_14__
Window.RequestFeature(WindowFeatures.ActionBar);
ActionBar.SetDisplayHomeAsUpEnabled(ViewModel.CanGoBack);
#endif
SetContentView(Resource.Layout.identityproviderlistview);
_loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) =>
{
if (ViewModel.LoadingIdentityProviders)
LoadingDialog.Show();
else
LoadingDialog.Dismiss();
InvalidateOptionsMenu();
});
ViewModel.LoginError += (sender, args) =>
{
var builder = new AlertDialog.Builder(this);
builder.SetTitle("Error");
builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
builder.SetMessage(args.Message);
builder.SetPositiveButton("Dismiss", (s, e) => { });
builder.Create().Show();
};
}
开发者ID:JoseManuelLopez,项目名称:Cheesebaron.MvxPlugins,代码行数:31,代码来源:DefaultLoginIdentityProviderListView.cs