I am using separate thread to get the json object from the url. but the problem is I would like to show the progress dialog while getting the result. I have create a progress di
Instead of you creating and handling a separate thread by yourself, use Asynctask. It will make your job easier. You can have a progress dialog displayed through out the execution of this async task and you can update the progress dialog from asynctask using publishProgress()
You can do it using AsyncTask..by adding the thread part into the doInBackground method..show the progress dialog in onPreExecute and dismiss it in onPostExecute..
ex:
public class MyTask extends AsyncTask<String, Void, String> {
private Context context;
private ProgressDialog progressDialog;
public MyTask (Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(context, "", "Loading...", true);
}
/*
* @see android.os.AsyncTask#doInBackground(Params[])
*/
@Override
protected String doInBackground(String... arg0) {
//your json thread part
}
@Override
protected void onPostExecute(final String result) {
progressDialog.dismiss();
}
}