[英]How to display MessageBox in Monodroid
如何在Xamarin.Android中顯示消息框? 如何從消息框中獲得是或否的響應?
- - 更新 :
myBtn.Click += (sender, e) =>
{
new AlertDialog.Builder(this)
.SetMessage("hi")
.Show();
};
您可以在Activity
使用AlertDialog.Buider
類。
new AlertDialog.Builder(this)
.SetPositiveButton("Yes", (sender, args) =>
{
// User pressed yes
})
.SetNegativeButton("No", (sender, args) =>
{
// User pressed no
})
.SetMessage("An error happened!")
.SetTitle("Error")
.Show();
試試這個:
public void ShowAlert (string str)
{
AlertDialog.Builder alert = new AlertDialog.Builder (this);
alert.SetTitle (str);
alert.SetPositiveButton ("OK", (senderAlert, args) => {
// write your own set of instructions
});
//run the alert in UI thread to display in the screen
RunOnUiThread (() => {
alert.Show ();
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.