Java 进程对话框上的许多方法无法解析
我创建了一个程序,用于从URL服务器下载带有进度条的文件 我使用了来自 但是我有一个小小的修改 我在课堂上使用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)
扩展活动
。并在异步任务上使用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的回答。很高兴你让它工作了。干杯