Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AsyncTask Progress bar [duplicate]

Possible Duplicate:
Progressbar togther with asyncTask

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.

like image 302
abhishek ameta Avatar asked Feb 06 '12 08:02

abhishek ameta


1 Answers

Please try this

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();
    };
 }

You can call this using

LoadData task = new LoadData();
task.execute();
like image 152
Sandy Avatar answered Sep 27 '22 16:09

Sandy