Progress Dialog for AsyncTask - Android

前端 未结 4 781
情深已故
情深已故 2021-01-06 19:16

I\'m trying to show a progress dialog while the twitter feed is loading up...However the progress dialog remains on screen when the twitter feed appears. Any help is much ap

4条回答
  •  孤街浪徒
    2021-01-06 20:04

    You must use a onPreExecute and onPostExecute of AsyncTask class. For example:

    class AsyncData extends AsyncTask{
    
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // init progressdialog
        }
    
    
        @Override
        protected Void doInBackground(Void... arg0) {
            // get data
            return null;
        }
    
    
        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // dismiss dialog
        }
    }
    

提交回复
热议问题