ProgressDialog不适用于对片段的参数 [英] ProgressDialog is not applicable for the arguments for fragment

查看:140
本文介绍了ProgressDialog不适用于对片段的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能在片段使用进度对话框。我试图用一个进度,但在活动对话框,和它的工作。

I can't use a progress dialog in a Fragment. I tried using a progress dialog in an Activity, however, and it worked.

下面是我的code部分:

Here's part of my code:

private class MyCustomWebViewClient extends WebViewClient {
      @Override
      public void onPageStarted(WebView view, String url, Bitmap favicon) {
          super.onPageStarted(view, url, favicon);
          final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...",
               true);
          pd.setCancelable(false);
          pd.setTitle("Please wait");
          pd.setMessage("Page is loading..");
          pd.show();
      }
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          view.loadUrl(url);
          return true;
      }

该错误是:


The method show(Context, CharSequence, CharSequence, boolean) in the type
ProgressDialog is not applicable for the arguments 
(CommunityFragment.MyCustomWebViewClient, String, String, boolean)

我该如何解决这个问题?

How can I fix this?

推荐答案

您有这样的:

final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...",
           true);

不是一个有效的范围内。使用 ActivityName.this 如果它是一个活动。如果它是一个片段使用 CommunityFragment.this.getActivity()

this is not a valid context. Use ActivityName.this if it's an Activity. If it's a Fragment use CommunityFragment.this.getActivity().

这篇关于ProgressDialog不适用于对片段的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆