I want to add a cancel button to my progress dialog but I can't compile the code. The IDE (eclipse) it's saying that there is an error in the code but I don't know what's wrong?
ProgressDialog ASYN_DIALOG = new ProgressDialog(getBaseContext());
ASYN_DIALOG.setMessage("Awaiting...");
ASYN_DIALOG.setButton("Cancel", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.e("ANDR: ", "Cancel clicked !");
}
});
I'm using API lvl 10 (Android 2.3.3)
The
setButton
method you are using is deprecated (although it should still work). Also, you might want to add the button before showing the dialog. Try: