作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 ActionBarSherlock,遇到了一个问题,我认为与导入有关(?)。
我正在尝试使用 onCreateDialog() 和 onPrepareDialog() 从 SherlockListFragment 显示自定义对话框。例如,onCreateDialog 看起来像这样:
@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;
}
这种方法在 SherlockActivity 中运行良好,但我在使用 SherlockListFragment 时遇到错误:
The method onCreateDialog(int) of type MyFragment must override or implement a supertype method
我在 onPrepareDialog() 中遇到了类似的错误。如上所述,MyFragment 扩展了 SherlockListFragment。
如果有任何解决此错误的建议,我将不胜感激。谢谢!
最佳答案
这些 API 已弃用,您应该使用 DialogFragments:http://developer.android.com/reference/android/app/DialogFragment.html
关于android - ActionBarSherlock onCreateDialog() 错误 : "must override or implement a supertype method",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13363199/
我是一名优秀的程序员,十分优秀!