How to implement progressBar while loading data?

后端 未结 4 1447
执笔经年
执笔经年 2021-02-06 08:24

I want to implement progressBar like on the picture below.

Right now, I have AsyncTask whic is sperated from fragments classes, and I use that AsyncTask to load data, an

4条回答
  •  暖寄归人
    2021-02-06 09:00

    class YourCLassName extends AsyncTask {
    
        private ProgressDialog pd = new ProgressDialog(Files.this);
    
        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
            pd.setTitle("your message");
    
            pd.show();
    
        }
    
        @Override
        protected Void doInBackground(String... params) {
                // YOUR PIECE OF CODE
    
            return null;
        }
    
        @Override
        protected void onPostExecute(Void result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
    
    
                pd.setMessage("Task Completed  .. whatever");
    
    
        @Override
        protected void onProgressUpdate(Integer... values) {
            // TODO Auto-generated method stub
            super.onProgressUpdate(values);
        }
    
    
    }
    

提交回复
热议问题