Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 进程对话框上的许多方法无法解析_Java_Android_Android Asynctask_Download_Progressdialog - Fatal编程技术网

Java 进程对话框上的许多方法无法解析

Java 进程对话框上的许多方法无法解析,java,android,android-asynctask,download,progressdialog,Java,Android,Android Asynctask,Download,Progressdialog,我创建了一个程序,用于从URL服务器下载带有进度条的文件 我使用了来自 但是我有一个小小的修改 我在课堂上使用扩展活动。并在异步任务上使用doInBackground 这是我的onCreate代码: String TAG_NAME; String fileUrl; TextView teksDownload; Dialog pDialog; // Progress dialog type (0 - for Horizontal progress bar)

我创建了一个程序,用于从URL服务器下载带有进度条的文件

我使用了来自

但是我有一个小小的修改

我在课堂上使用
扩展活动
。并在异步任务上使用doInBackground

这是我的onCreate代码:

String TAG_NAME;
    String fileUrl;
    TextView teksDownload;

    Dialog pDialog;
    // Progress dialog type (0 - for Horizontal progress bar)
    public static final int progress_bar_type = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_download);

        TAG_NAME= getIntent().getStringExtra("nama_file");

        fileUrl="http://myserver.com/"+TAG_NAME;

        teksDownload= (TextView) findViewById(R.id.teksDownload);
        teksDownload.setText("Downloading "+fileUrl);

        new DownloadFileFromURL().execute(fileUrl);

    }
我使用
protecteddialog onCreateDialog(int-id)
classdownloadfilefromURL扩展AsyncTask
方法。类似这样的代码

结果,我有5个错误

找不到符号方法
setMessage(String)
setIndeterminate(boolean)
setMax(int)
setProgressStyle(int)
setProgress(int)

关于此代码:

case progress_bar_type:
                pDialog = new ProgressDialog(this);
                pDialog.setMessage("Downloading file. Please wait...");
                pDialog.setIndeterminate(false);
                pDialog.setMax(100);
                pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                pDialog.setCancelable(true);
                pDialog.show();
                return pDialog;
protected void onProgressUpdate(String... progress) {
            // setting progress percentage
            pDialog.setProgress(Integer.parseInt(progress[0]));
        }
该代码:

case progress_bar_type:
                pDialog = new ProgressDialog(this);
                pDialog.setMessage("Downloading file. Please wait...");
                pDialog.setIndeterminate(false);
                pDialog.setMax(100);
                pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                pDialog.setCancelable(true);
                pDialog.show();
                return pDialog;
protected void onProgressUpdate(String... progress) {
            // setting progress percentage
            pDialog.setProgress(Integer.parseInt(progress[0]));
        }

请再次检查引用的链接。 他使用了
private ProgressDialog pDialog但您正在使用
对话框


Dialog
没有这些方法。

您已将
pDialog
声明为常规的
Dialog
,该对话框没有这些方法。将声明更改为
ProgressDialog pDialog@MikeM。非常感谢,你为什么在评论中回答?我不能标记或接受它作为一个正确的答案,如果你回答这个评论。我正在寻找一个重复的。我很确定我以前见过这个问题,但我找不到。如果你愿意,你可以接受Pawneshwer Gupta的回答。很高兴你让它工作了。干杯