xamarin.forms - 单击警报外部时如何限制显示警报的关闭
问题描述
我正在将 xamarin.forms 用于 Android 应用程序,我需要在左侧显示警报,在右侧显示 YES 和 NO。我可以管理它,将 YES 交换为 NO 并将 NO 交换为 YES,但是当默认单击警报之外时,它被视为 YES。
我怎样才能做到这一点?
解决方案
我使用了类似的东西,它工作得很好,尽管我注意到它可能不是面向未来的。如果用户没有单击“是”,则显示将消失而无需执行任何其他操作。
bool continue_logout = false;
try
{
continue_logout = await DisplayAlert("Logout", "If you logout, you also clear the cache of all data. Are you sure you want to continue?", "Yes", "No");
if (continue_logout)
{
// Clean up stuff and clear out user settings
}
}
catch {
}
finally
{
if (continue_logout)
App.Current.MainPage = new NavigationPage(new LoginPage());
}
推荐阅读
- html - 在“缩放”状态下加载移动页面
- json - 从jmeter中的json提取和添加多个值
- git - 如何使用 git 进行三向图形差异(不合并)?
- c - 如何通过环绕将 4 字节数组移动所有 32 位?
- io - 无法设置两个 GB_IO 引脚
- mysql - 将大量数据从 XML 文件转换为数据库
- node.js - 如何从 Seneca 中的匹配模式中获得响应?
- node.js - 如何删除一个列表的内容不只是列表?如果 x 在 y 中,则在删除 x 时也删除 y
- sas - SAS:在执行 ARIMA 建模和预测时,您如何指定股票价格的区间,因为您会错过几天?
- c++ - 如何将使用Qt制作的记事本设置为Windows中的默认文本编辑器