Show Dialog, on Fragment working
<p>I have a Fragment and at its onStart(), I made a lot of BD querys, that are long for 15 seconds. I want to show a Progress Dialog, with a "loading circle". 
My app, has just one Activity, the Main. This, starts the first Fragment, and from this, I jump to other Fragment, and the same for the next. For to pass from one Fragment to other, I use the next static method.</p>

<pre><code>public static startFragment(FragmentTransaction FT, Fragment newFragmentToOpen)
{
   FT.replace(R.id.Container, newFragmentToOpen);
   FT.addToBackStack(null);
   FT.commit();
}
</code></pre>

<p>I tried make a Thread in that method what starts the Progress Dialog, but it didn´t work. I tried to start the dialog on the OnCreate() method of the Fragment, and that didn´t work too.</p>

<p>What can I do?</p>

<p>Thank you.</p>

<p>(Edit)
I tried to start the Progress Dialog inside of the Fragment, at the onCreateView() and at onViewCreated(). It didn´t work, but if I debug step by step, I see that at the moment when the flow goes to the onStart() (where it is for 10 seconds usinig a DB), the ProgressDialog stops. </p>

<p>By this test, I understand, that the ProgressDialog is correctly showed, but when I go to onStart(), it disappear.</p>

<p>(Edit)</p>

<p>The problem is, that at the onStart() of the Fragment, I am working on the views, addking elements. I need, that while these elements are loading, a dialog be showed, because now, for the user it seems that the app is sttoped while it loads. I would need something like this:</p>

<pre><code>public static startFragment(FragmentTransaction FT, Fragment newFragmentToOpen)
{
    startProgressDialog();

    FT.replace(R.id.container, newFragmentToOpen);
    FT.addToBackStack(null);
    FT.commit();

    stopProgressDialog();
}
</code></pre>

<p>But it doesn´t work, because the progress Dialog just begins when the view of the Fragment is fully loaded.</p>