説明するのが少し難しい問題なので、しばらくお待ちください
リストビューのすべてのリストアイテムにプログレスバーがあり、ダウンロードを表示して単一のビューを更新するために使用されます単一のアイテムのビューオブジェクトを取得し、このビューが非同期タスクに渡され、ダウンロードが進行中のビューのみを更新します
リストビューのランダムなリストアイテムに対してリストビューの進行状況バーが表示されると、リストビューをスクロールするまで正常に動作します
asynctask を呼び出すコード
ListView lv = getListView();
int visiblePosition = lv.getFirstVisiblePosition();
View v = lv.getChildAt(position - visiblePosition);
v.setClickable(true);
task = new TestLoadingTask();
task.v = lv.getChildAt(position - visiblePosition);
executeAsyncTask(task, null, null, null);
非同期タスクの進捗状況の更新について
@Override
protected void onProgressUpdate(Object... values) {
super.onProgressUpdate(values);
progress[currentposition] = (Integer)values[0];
max[currentposition] = 100;
updateprogress(currentposition,v);
}
public void updateprogress(int position,View v)
{
ProgressBar update = (ProgressBar)v.findViewById(R.id.downloadbar);
if(max!=null && max[position]!=0)
update.setMax(max[position]);
if(progress!=null)
update.setProgress(progress[position]);
TextView tv_per = (TextView) v.findViewById(R.id.percentage);
if(progress[position]==max[position])
{
tv_per.setVisibility(View.GONE);
update.setVisibility(View.GONE);
}
else
{
tv_per.setVisibility(View.VISIBLE);
tv_per.setText(progress[position]+"/"+max[position]);
update.setVisibility(View.VISIBLE);
}
}
参照/アドバイス/例をいただければ幸いです。