Rak*_*esh 8 c# android xamarin.android android-progressbar
创建了一个循环进度条,它与动画一起正常工作.但在尝试使用动态数据显示它时,进度条不会更新.
下面的代码工作正常
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();
Run Code Online (Sandbox Code Playgroud)
和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" />
Run Code Online (Sandbox Code Playgroud)
但是当我在循环中尝试类似的东西时,进度条没有更新数据.基本上进度条没有在圆圈中更新.
for (int i = 0; i <= 100; i++)
{
int cnt = 0;
cnt = cnt + i;
progrssBarObj.Progress = cnt;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
我把for循环保留在新任务中并且它已经工作了
await Task.Run(() =>
{
for (int i = 0; i < dtITM.Rows.Count; i++)
{
int cnt = 0;
cnt = cnt + i;
progrssBarObj.Progress = cnt;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2949 次 |
最近记录: |