D. Aji Pratama D. Aji Pratama - 2 months ago 18
Android Question

Many method on progress dialog cannot resolved

I create a program for downloading file with progress bar from URL server.

I use a reference from Android Hive

But I have a modify this a little.

I use

extends Activity
on my class. and use doInBackground on AsyncTask.

This is for my onCreate code:

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);

}


I use
protected Dialog onCreateDialog(int id)
and
class DownloadFileFromURL extends AsyncTask<String, String, String>
Method. Approximately same code like this Reference.

And result, I Have 5 Error.

cannot find symbol method
setMessage(String)
,
setIndeterminate(boolean)
,
setMax(int)
,
setProgressStyle(int)
,
setProgress(int)
.

on this code:

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;


and this code:

protected void onProgressUpdate(String... progress) {
// setting progress percentage
pDialog.setProgress(Integer.parseInt(progress[0]));
}

Answer

please check your referenced link again. he used private ProgressDialog pDialog; but you are using Dialog.

Dialog doesn't have those methods.

Comments