大家都在列表视图中有两个按钮。当我点击拒绝按钮时,Alertdialog将来到那里我必须输入原因..在确定后输入原因点击AlertDialog应该解雇。
每件东西都保存到DB ..但是警告对话框没有关闭...而是在进入三次关闭之后...我已经在下面找到了我的代码。
btnReject.Click += delegate
{
var currentItem = item;
Console.WriteLine(position);
AlertDialog.Builder alert = new AlertDialog.Builder(this.context);
LayoutInflater inflater = Application.Context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
View viewdialog = inflater.Inflate(Resource.Layout.RejectJobsAlertDialog, null);
EditText getreason = viewdialog.FindViewById<EditText>(Resource.Id.Reason);
alert.SetTitle("Reject Reason ");
alert.SetView(viewdialog);
alert.SetPositiveButton("Ok", (senderAlert, args) =>
{
item.RejectedReason = getreason.Text;
sharedasproxy.MobileJobdetailsUpdate(item, BASE_URL + "/xxxxx");
Toast.MakeText(this.context, "success!", ToastLength.Short).Show();
btnReject.Visibility = ViewStates.Invisible;
btnAccept.Visibility = ViewStates.Visible;
dialog.Cancel();
});
alert.SetNegativeButton("Cancel", (senderAlert, args) =>
{
Toast.MakeText(this.context, "Cancelled!", ToastLength.Short).Show();
CloseDialog();
});
dialog = alert.Create();
dialog.Show();
};
答案 0 :(得分:2)
尝试以下内容,
if (!btnReject.HasOnClickListeners)
{
btnReject.Click += delegate
{
var currentItem = item;
AlertDialog.Builder alert = new AlertDialog.Builder(this.context);
LayoutInflater inflater = Application.Context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
View viewdialog = inflater.Inflate(Resource.Layout.RejectJobsAlertDialog, null);
EditText getreason = viewdialog.FindViewById<EditText>(Resource.Id.Reason);
alert.SetTitle("Reject Reason ");
alert.SetView(viewdialog);
alert.SetPositiveButton("Ok", (senderAlert, args) =>
{
item.RejectedReason = getreason.Text;
sharedasproxy.MobileJobdetailsUpdate(item, BASE_URL + "/xxxxx");
Toast.MakeText(this.context, "success!", ToastLength.Short).Show();
btnReject.Visibility = ViewStates.Invisible;
btnAccept.Visibility = ViewStates.Visible;
dialog.Cancel();
});
alert.SetNegativeButton("Cancel", (senderAlert, args) =>
{
Toast.MakeText(this.context, "Cancelled!", ToastLength.Short).Show();
CloseDialog();
});
dialog = alert.Create();
dialog.Show();
};
}