AsyncTask를 사용하여 데이터를로드하고 작업 진행률을 나타내는 값을 반환 할 수 있습니다. 진행 막대로 표시하려는보기를 작성한 다음 asynctask를 작성하고 활동 컨텍스트와 진행 막대를 전달할 수 있습니다.
public class Loader extends AsyncTask<>{
ProgressBar progress;
Context context;
public Loader(Context context, ProgressBar progress)
{
this.progress = progress;
this.context = context;
}
public Integer doInBackground()
{
// do your loading here and determine what percent is done and call publishProgress()
}
public void onProgressUpdate(Integer... value)
{
final Integer progressVal = value;
Runnable updateProg = new Runnable(){
public void run(){
this.progress.setProgress(progressVal);
}};
Handler main = new Handler(context.getMainLooper());
main.post(updateProg);
}