public static class AlertExtension
{
public static void ShowAlert(this Activity activity ,string msg,string title = "", string btnText = "OK"){
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.SetTitle(title);
builder.SetMessage(msg);
builder.SetCancelable(false);
builder.SetPositiveButton(btnText, delegate {
// it is alert ,keep it simple , do nothing here
});
builder.Show();
}
}
使用时:
if(txtPwd.Text != txtCfmPwd.Text){
this.ShowAlert("Password and confirmed password not match");
}