new AsyncTask<Void, Void, String>(){ ProgressDialog progressDialog; protected void onPreExecute() { progressDialog = new ProgressDialog(EditSelectedActivity.this); progressDialog.setMessage(getResources().getString(R.string.d_loading)); progressDialog.show(); }; @Override protected String doInBackground(Void... params) { return null; } protected void onPostExecute(String result) { if (progressDialog != null) progressDialog.dismiss(); } }.execute(null,null);
i usually use 'view.post(Runnable r)' to post a time-consuming operation. but progressdialog does not work. i could see the progress dialog when the app runs. but i found using 'thread' or 'asyntask' work well.