I am trying to call an alert dialog from another class but this is not letting me set it to static. It shows as only final is permitted and that means it cannot call it from the other class. I'm not sure if I am doing it correctly or if it is even possible. I have the alert dialog in class 2:
static final AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
alertDialog = new AlertDialog.Builder(this).create();
alertbox.setTitle("Hello");
alertbox.setMessage("Press Continue or Cancel");
alertbox.setPositiveButton("CONTINUE",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertbox.setNegativeButton("CANCEL",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.setIcon(R.drawable.icon);
This then gets called in class1:
QuizValidation.alertbox.show();
Which also cannot be resolved.
I can probably sort that out if I could set the alertbox in class 2 to static.
Would appreciate any advice.
Thanks