How to center progress indicator in ProgressDialog easily (when no title/text passed along)

后端 未结 8 885
死守一世寂寞
死守一世寂寞 2020-11-28 00:43

When calling progressDialog = ProgressDialog.show(this, null, null, true); usually the developers wants to only show the progress indication image, and usually

8条回答
  •  忘掉有多难
    2020-11-28 01:04

    You can always add one ProgressBar in all your activities where you might want to show centered ProgressDialog. Use following in acitivity.xml As:

    
    

    In your Acitivity.java, use

    ProgressBar bar = new Progress();
    bar = (ProgressBar) findViewById(R.id.progressBar);
    

    Now when you want to show the ProgressBar, just set its visibility to visible, and to cancel, set visibility to gone.

    bar.setVisibility(View.VISIBLE);
    bar.setVisibility(View.GONE);
    

提交回复
热议问题