Android AsyncTask 进度条 [英] Android AsyncTask Progress bar

查看:21
本文介绍了Android AsyncTask 进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
进度条与 asyncTask 一起

我在一个项目中有一个 expandableListView .如果有人点击组,那么数据必须加载,加载时间必须出现进度条.我想通过异步任务来完成.请给我示例代码.提前致谢.

I am having a expandableListView in a project . If somebody clicks on the group then data must be load and loading time a progress bar must come.I want to do it by Async Task .please give me example code for that. Thanks in advance.

推荐答案

请试试这个

public class LoadData extends AsyncTask<Void, Void, Void> {
    ProgressDialog progressDialog;
    //declare other objects as per your need
    @Override
    protected void onPreExecute()
    {
        progressDialog= ProgressDialog.show(YourActivity.this, "Progress Dialog Title Text","Process Description Text", true);

        //do initialization of required objects objects here                
    };      
    @Override
    protected Void doInBackground(Void... params)
    {   

         //do loading operation here  
        return null;
    }       
    @Override
    protected void onPostExecute(Void result)
    {
        super.onPostExecute(result);
        progressDialog.dismiss();
    };
 }

您可以使用

LoadData task = new LoadData();
task.execute();

这篇关于Android AsyncTask 进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆