How to change the ProgressDialog Message font size in android programmatically?

前端 未结 3 2103
谎友^
谎友^ 2021-02-06 18:00

I have used progressDialog in my android application and i have used code as

ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.se         


        
3条回答
  •  借酒劲吻你
    2021-02-06 18:24

    Make custom progress dialog like below:

    custom_progress_dialog.xml

    
      
    
    

    MyCustomProgressDialog.java

    public class MyCustomProgressDialog extends ProgressDialog {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.custom_progress_dialog);
    
          ...
        }
        public static MyCustomProgressDialog ctor(Context context) {
            MyCustomProgressDialog dialog = new MyCustomProgressDialog(context);
            dialog.setIndeterminate(true);
            dialog.setCancelable(false);
            return dialog;
        }
    
    
         @Override
         public void show() {
            super.show();
        }
    
        @Override
        public void dismiss() {
          super.dismiss();
         }
    
    
    }
    

    and then use progress dialog class in asynctask like below:

    class DemoAsyncTask extends AsyncTask {
      private final MyCustomProgressDialog progressDialog;
    
      public DemoAsyncTask(Context ctx) {
        progressDialog = MyCustomProgressDialog.ctor(ctx);
      }
    
      @Override
      protected void onPreExecute() {
        super.onPreExecute();
        textView.setVisibility(View.INVISIBLE);
    
        progressDialog.show();
      }
    

提交回复
热议问题