【问题标题】:c# xamarin circular progress bar - Androidc# xamarin 圆形进度条 - Android
【发布时间】:2016-08-22 20:39:09
【问题描述】:

创建了一个与动画配合良好的圆形进度条。但是在尝试使用动态数据进度条显示它时没有更新。

下面的代码正在运行

  progrssBarObj = FindViewById<ProgressBar>(Resource.Id.progressBarSync);

  ObjectAnimator animation = ObjectAnimator.OfInt(progrssBarObj, "progress", 0, 100); // see this max value coming back here, we animale towards that value
  animation.SetDuration(3000); //in milliseconds
  animation.SetInterpolator(new DecelerateInterpolator());
  animation.Start();

AXML 代码是

<ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_column="2"
            android:id="@+id/progressBarSync"
            android:layout_width="300dp"
            android:layout_height="300dp"
            android:progressDrawable="@drawable/circular_progress_bar"
            android:background="@drawable/progress_bar_background" />

但是当我在循环中尝试类似的操作时,进度条不会随数据更新。基本上进度条不会循环更新。

           for (int i = 0; i <= 100; i++)
            {
                int cnt = 0;
                cnt = cnt + i;
                progrssBarObj.Progress = cnt;

            }

我们将不胜感激。

【问题讨论】:

    标签: c# android xamarin.android android-progressbar


    【解决方案1】:

    我在新任务中保留了 for 循环,它成功了

    await Task.Run(() =>
    {
      for (int i = 0; i < dtITM.Rows.Count; i++)
      {
        int cnt = 0;
        cnt = cnt + i;
        progrssBarObj.Progress = cnt;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-12-21
      • 2023-04-08
      • 1970-01-01
      • 2016-09-19
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多