在 C# 中,Make 按钮会在 5 秒后永远出现
Make button appears after 5 seconds forever in C#
在我的 Xamarin 应用程序中,有一个按钮,我想让它在 5 秒后可见。
我试过 Device.StartTimer
,但它使按钮在 5 秒后出现,然后在 5 秒后隐藏它,然后在 5 秒后再次出现(永远)。
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
// Button
return true;
});
如何让按钮在 5 秒后出现,并且永不消失?
您也可以在 C# 代码中使用 Thread.sleep(5000); 方法。
保持线程 5 秒钟,然后该按钮将显示在屏幕上。
我想你需要的是 return false 这样定时器只运行一次。
即:
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
/* Make your button appears here */
// ...
return false;
});
在我的 Xamarin 应用程序中,有一个按钮,我想让它在 5 秒后可见。
我试过 Device.StartTimer
,但它使按钮在 5 秒后出现,然后在 5 秒后隐藏它,然后在 5 秒后再次出现(永远)。
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
// Button
return true;
});
如何让按钮在 5 秒后出现,并且永不消失?
您也可以在 C# 代码中使用 Thread.sleep(5000); 方法。 保持线程 5 秒钟,然后该按钮将显示在屏幕上。
我想你需要的是 return false 这样定时器只运行一次。
即:
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
/* Make your button appears here */
// ...
return false;
});