progress bar appear before that i click on button to create PDF : why progress bar appear before that i click on button to create PDF?
I hope that you can help me!

I want that progress bar appear during creation PDF file...

THANKS IN ADVANCED EVERYBODY!

        @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                     Bundle savedInstanceState) {
                // Inflate the layout for this fragment
        
                View rootView = inflater.inflate(R.layout.fragment_two, container, false);
                pdfProgress = (ProgressBar)rootView.findViewById(R.id.progressbar);
        
        
        
                Button mButton = (Button) rootView.findViewById(R.id.newbutton);
                mButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
        
                        //sendemail();
                        pdfProgress.setVisibility(View.VISIBLE);
                        createPDF();
                        pdfProgress.setVisibility(View.GONE);
                        viewPDF();
        
        
        
                    }
                });
    
    TextView titolo3 = (TextView)rootView.findViewById(R.id.result);
            TextView titolo2 = (TextView)rootView.findViewById(R.id.result2);
            TextView titolo4 = (TextView)rootView.findViewById(R.id.resultpizze);