我当前有2个 PopupWindow
,一个立即在Button
按下解散。
private async void ClosePopupWindow(object sender, View.TouchEventArgs e)
{
_popUpReceiptWindow.Dismiss();
await Task.Delay(5000);
Intent intent = new Intent(this, typeof(MainActivity));
intent.SetFlags(Intent.Flags);
Finish();
}
由于PopupWindow
的性质,它关闭,然后切换到其他Activity
。
无法正确解散的窗口是这条代码。
private void CloseEftWindow(object sender, View.TouchEventArgs e)
{
_popupEftWindow.Dismiss();
}
这是窗口的初始化,无法正确关闭:
private void EftButton_OnTouchedAsync(object sender, View.TouchEventArgs e)
{
_eftButton.Touch -= EftButton_OnTouchedAsync;
var popupEftView = LayoutInflater.Inflate(Resource.Layout.CreditCardPopupWindow, null);
_creditCardState = EftType.EftCardInserted;
_popUpCashbackButton = popupEftView.FindViewById<Button>(Resource.Id.popupCreditCardCashBackButton);
_popupEFTCancelButton = popupEftView.FindViewById<Button>(Resource.Id.popupCreditCardCancel);
_popupEftWindow = new PopupWindow(popupEftView, _subTotalLayout.Width, 500, true);
_popupEftWindow.ShowAtLocation(_subTotalLayout, GravityFlags.Bottom, 0, 0);
_popupEFTCancelButton.Touch += CloseEftWindow;
SubscribeCreditCardElements(popupEftView);
CreditCardStateTranstion(EftType.EftCardInserted);
_popUpCashbackButton.Touch += CashbackButtonSelected;
_eftButton.Touch += EftButton_OnTouchedAsync;
}
这是正确关闭的初始化:
private void UnderZeroBalanceReached()
{
View popUpView = LayoutInflater.Inflate(Resource.Layout.PopupView, null);
if (_totalAmount <= 0)
{
_popUpOkButton = popUpView.FindViewById<Button>(Resource.Id.popupReceiptYesButton);
_popUpReceiptWindow = new PopupWindow(popUpView, _subTotalLayout.Width, 500, true);
_popUpReceiptWindow.ShowAtLocation(_subTotalLayout, GravityFlags.Bottom, 0, 0);
_popUpOkButton.Touch += ClosePopupWindow;
DisableRightSidePaneButtons();
}
}
有人能看到我在做什么错吗?我在解雇EFT弹出窗口时使用了断点,但看不到为什么它实际上没有关闭。
我不确定为什么,但是在方法中,在方法中,有些代码行会禁用元素,例如按钮和文本视图,并使它们变得不可见。弹出窗口只有在启动它已被禁用并使其不可见的按钮时才会被驳回。