c# - 标签不会在旧系统版本上更新 - xamarin

标签 c# android xamarin

我有问题。

标签不会在旧版本上更新。 在 android 系统版本 8.1 上一切正常,但例如在 7.1 版本刷新标签不起作用。

  private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
        {
            var lab_seconds = FindViewById<TextView>(Resource.Id.textView_seconds);
            lab_seconds.Text = (Int32.Parse(lab_seconds.Text) -1).ToString();
            lab_seconds.RefreshDrawableState();
}

最佳答案

假设您的计时器回调不在 UI 线程上:

private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
    RunOnUiThread(() =>
    {
        var lab_seconds = FindViewById<TextView>(Resource.Id.textView_seconds);
        lab_seconds.Text = (Int32.Parse(lab_seconds.Text) -1).ToString();
     });
}

关于c# - 标签不会在旧系统版本上更新 - xamarin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53592459/

相关文章:

android - 检查 Android 应用程序可用磁盘空间的正确方法?

android - 了解 android 中的 mixer_paths.xml

xamarin.android - 在 Xamarin 中动态创建 android 微调器

c# - 如何按顺序匹配正则表达式命名的捕获组

c# - 如何在 Gtk# 中将上下文菜单添加到树节点?

c# - 我如何使用垃圾收集器?

c# - OraOLEDB.Oracle 提供程序未在本地计算机上注册

android - Android 包安装期间写入元信息

ios - Visual Studio 中仅支持 ARM64 架构

android - 如何在 Activity(Xamarin.Android) 之外使用 FilesDir.Path 属性?