How do I show and then remove an android progress dialog

前端 未结 3 1072
遇见更好的自我
遇见更好的自我 2020-12-11 21:47

I can get a progress bar to appear with the following code

pd = ProgressDialog.show(myActivity.this, \"\", \"Loading. Please wait...\", true);
3条回答
  •  死守一世寂寞
    2020-12-11 22:46

    here is the code that I got to work

    private class UpdateFeedTask extends AsyncTask {
    
        private ProgressDialog mDialog;
    
        protected void onPreExecute() {
            Log.d(TAG, " pre execute async");
            mDialog = ProgressDialog.show(MyActivity.this,"Please wait...", "Retrieving data ...", true);
    
        }
    
        protected void onProgressUpdate(Void... progress) {
            Log.d(TAG, " progress async");     
        }
    
        @Override
        protected Void doInBackground(MyActivity... params) {
            // TODO Auto-generated method stub
            return null;
        }
    
        protected void onPostExecute(Void result) {
            Log.d(TAG, " post execute async");
            mDialog.dismiss();
        }
    
    }
    

提交回复
热议问题