I’m using ActionBarSherlock, and running into a problem, I think related to imports (?).
I’m trying to use onCreateDialog() and onPrepareDialog() to present a custom dialog box from a SherlockListFragment. For example, the onCreateDialog looks something like this:
@Override
protected Dialog onCreateDialog(int id) {
AlertDialog alert = null;
switch (id) {
case DIALOG_CASE_1:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(question)
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// do stuff
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alert = builder.create();
break;
default:
alert = null;
}
return alert;
}
This approach works fine from a SherlockActivity, but I’m getting an error with SherlockListFragment:
The method onCreateDialog(int) of type MyFragment must override or implement a supertype method
I get a similar error for onPrepareDialog(). As indicated above, MyFragment extends SherlockListFragment.
I would greatly appreciate any suggestions to resolve this error. Thanks!
These APIs are deprecated, you’re supposed to be using DialogFragments: http://developer.android.com/reference/android/app/DialogFragment.html