2016-08-16 176 views
8

創建了一個圓形進度條,可以與動畫一起正常工作。但在嘗試使用動態數據進度條進行顯示時並未更新。c#xamarin圓形進度條 - Android

下面代碼工作

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; 

      } 

任何幫助將不勝感激。

回答

6

我在新的任務保持在for循環中,它得到了工作

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