2

这是 LogCat 所说的:

01-21 17:20:06.057: ERROR/AndroidRuntime(27463): java.lang.NoSuchMethodError: com.mohit.geo2do.activities.TasksList.showDialog
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.mohit.geo2do.activities.TasksList.onContextItemSelected(TasksList.java:190)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.app.Activity.onMenuItemSelected(Activity.java:2183)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2785)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:140)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:129)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:898)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.widget.AdapterView.performItemClick(AdapterView.java:301)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.widget.ListView.performItemClick(ListView.java:3626)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:3600)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.os.Handler.handleCallback(Handler.java:587)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.os.Looper.loop(Looper.java:123)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at android.app.ActivityThread.main(ActivityThread.java:4363)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at java.lang.reflect.Method.invoke(Method.java:521)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
01-21 17:20:06.057: ERROR/AndroidRuntime(27463):     at dalvik.system.NativeStart.main(Native Method)

我在这句话上得到一个错误:

Bundle args = new Bundle();
args.putLong("id", ...);           //Some arbitrary value
showDialog(DELETE_DIALOG, args);

我有一个onPrepareDialog方法:

@Override
protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
    switch (id) {
    case DELETE_DIALOG:
        AlertDialog log = (AlertDialog) dialog;
        final Bundle bundle = args;
        log.setButton(DialogInterface.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                long id = bundle.getLong("id");

                getContentResolver().delete(Tasks.CONTENT_URI, Tasks._ID + "=" + id, null);
                adapter.notifyDataSetChanged();
            }
        });
        break;
    default:
        break;
    }
}

可能是什么问题呢?

4

2 回答 2

6

通常这意味着您编译的类和您运行的类是不同的版本。您正在调用的方法可供编译器访问,但在运行时对 JVM 不可用。

于 2011-01-21T22:43:21.783 回答
2

只有 API8 和更高版本有它。低于它只有 Activity.showDialog (int)。

于 2011-04-15T11:25:22.033 回答