can not override showDialog in Activity tab
Posted
by
hornetbzz
on Stack Overflow
See other posts from Stack Overflow
or by hornetbzz
Published on 2012-08-29T08:59:00Z
Indexed on
2012/08/29
9:38 UTC
Read the original article
Hit count: 290
Trying to downgrade my appl from android 2.2 (API 8) down to android 2.1 (API7), I'm facing some issues with dialog boxes. Based on this thread, I'm trying to catch these exceptions but can't override the showDialog method.
I turned the Java compiler from 1.5 to 1.6 according to this answer to a similar issue, but no changes, Eclipse still returns :
Cannot override the final method from Activity
public class MyActivity extends Activity implements
SeekBar.OnSeekBarChangeListener {
// ... some stuffs
@Override // here is the issue
public void showDialog(int dialogId) {
try {
super.showDialog(dialogId);
} catch (IllegalArgumentException e) {
Log.e(ACTIVITY_TAG, "Error dialog");
}
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_ALERT:
// Create out AlertDialog
Builder builder = new AlertDialog.Builder(this);
builder.setMessage(msg);
builder.setCancelable(false);
builder.setPositiveButton(GOTO_BOOK, new OkOnClickListener());
builder.setNegativeButton(STAY_HERE, new CancelOnClickListener());
AlertDialog dialog = builder.create();
dialog.show();
break;
case DIALOG_ONCREATE:
// Create out AlertDialog during the "onCreate" method (only "Ok"
// button)
Builder builder2 = new AlertDialog.Builder(getParent());
builder2.setMessage(msg);
builder2.setCancelable(false);
builder2.setPositiveButton(GO_BACK, new OkOnClickListener());
AlertDialog dialog2 = builder2.create();
dialog2.show();
break;
}
return super.onCreateDialog(id);
}
// ... some stuffs
}
© Stack Overflow or respective owner