title: How do I display ProgressDialog using Fragment
body: <p>I have a Fragment activity that has a ListFragment on the left and a Fragment on the right that has a WebView.  The functionality works fine but I would like to display a progress dialog showing "Loading..." while the web page finishes loading.  How can I accomplish this seemingly trivial task?</p>
  
  <p>Below is my code:</p>
  
  <pre><code>public class ArticleListActivity extends FragmentActivity implements
      ArticleListFragment.OnArticleSelectedListener {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.articlelist_fragment);
      }
  
      public void onArticleSelected(String contentLink) {
          ArticleViewerFragment viewer = (ArticleViewerFragment) getSupportFragmentManager()
                  .findFragmentById(R.id.articleview_fragment);
  
          if (viewer == null || !viewer.isInLayout()) {
              Intent showContent = new Intent(getApplicationContext(),
                      ArticleViewerActivity.class);
  
              showContent.setData(Uri.parse(contentLink));
              startActivity(showContent);
          } else {
              viewer.updateUrl(contentLink);
          }
      }
  }
  </code></pre>
  
  <p>Here is my FragmentActivity</p>
  
  <pre><code>public class ArticleViewerActivity extends FragmentActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.articleview_fragment);
  
          Intent launchingIntent = getIntent();
          String content = launchingIntent.getData().toString();
  
          ArticleViewerFragment viewer = (ArticleViewerFragment) getSupportFragmentManager()
                  .findFragmentById(R.id.articleview_fragment);
  
          viewer.updateUrl(content);
      }
  }
  </code></pre>
  
  <p>and here is my Fragment</p>
  
  <pre><code>public class ArticleViewerFragment extends Fragment {
  
      private ProgressDialog progressBar; 
  
      private WebView viewer = null;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          viewer = (WebView) inflater.inflate(R.layout.webview_layout, container, false);
          viewer.loadUrl("file:///android_asset/default.html");
          return viewer;
      }
  
      public void updateUrl(String newUrl) {
          if (viewer != null) {
              viewer.loadUrl(newUrl);
          }
      }
  }
  </code></pre>