应用程序在删除void后不会打开

时间:2013-01-04 09:12:21

标签: android intellij-idea

我刚刚开始使用android并且我的MainActivity类在'addItem'中有一个空格,我想在每次删除应用程序强制关闭的void时移动到另一个类

如何在不干扰应用程序操作的情况下删除空白?我已经搜索了项目的路径,无法找到它的任何引用,所以我不知道为什么它不起作用。

如果有帮助的话,我在Windows 7上使用IntelliJ

*的 更新 *

更详细一点,目前应用程序中没有太多内容;这是ActivityMain:

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;


public class ActivityMain extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_main);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_main, menu);
        return true;
    }

    public void addItem(MenuItem menuItem) {



    }

我已经创建了另一个将在其中添加addItem的类,但是当我从这里删除它并尝试运行应用程序时它会停止

这是logcat错误

01-04 09:15:04.268: ERROR/AndroidRuntime(2179): FATAL EXCEPTION: main
        android.view.InflateException: Couldn't resolve menu item onClick handler addItem in class com.spences10apps.SScript.ActivityMain
        at android.view.MenuInflater$InflatedOnMenuItemClickListener.<init>(MenuInflater.java:217)
        at android.view.MenuInflater$MenuState.setItem(MenuInflater.java:417)
        at android.view.MenuInflater$MenuState.addItem(MenuInflater.java:451)
        at android.view.MenuInflater.parseMenu(MenuInflater.java:188)
        at android.view.MenuInflater.inflate(MenuInflater.java:110)
        at com.spences10apps.SScript.ActivityMain.onCreateOptionsMenu(ActivityMain.java:25)
        at android.app.Activity.onCreatePanelMenu(Activity.java:2490)
        at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:407)
        at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:769)
        at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:201)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
        at android.view.Choreographer.doCallbacks(Choreographer.java:562)
        at android.view.Choreographer.doFrame(Choreographer.java:531)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
        at android.os.Handler.handleCallback(Handler.java:725)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5191)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.NoSuchMethodException: addItem [interface android.view.MenuItem]
        at java.lang.Class.getConstructorOrMethod(Class.java:460)
        at java.lang.Class.getMethod(Class.java:915)
        at android.view.MenuInflater$InflatedOnMenuItemClickListener.<init>(MenuInflater.java:215)
        ... 22 more
01-04 09:15:04.275: WARN/ActivityManager(426): Force finishing activity com.spences10apps.SScript/.ActivityMain
01-04 09:15:04.361: DEBUG/dalvikvm(426): GC_CONCURRENT freed 833K, 23% free 6881K/8840K, paused 7ms+6ms, total 87ms
01-04 09:15:04.361: DEBUG/dalvikvm(426): WAIT_FOR_CONCURRENT_GC blocked 37ms
01-04 09:15:04.424: DEBUG/dalvikvm(426): GC_FOR_ALLOC freed 42K, 18% free 7335K/8840K, paused 41ms, total 41ms
01-04 09:15:04.424: INFO/dalvikvm-heap(426): Grow heap (frag case) to 8.481MB for 1127536-byte allocation
01-04 09:15:04.463: DEBUG/dalvikvm(426): GC_FOR_ALLOC freed 2K, 16% free 8434K/9944K, paused 41ms, total 41ms
01-04 09:15:04.861: WARN/ActivityManager(426): Activity pause timeout for ActivityRecord{4143dab8 u0 com.spences10apps.SScript/.ActivityMain}
01-04 09:15:05.041: INFO/ActivityManager(426): No longer want com.google.android.talk (pid 1381): empty #17

1 个答案:

答案 0 :(得分:0)

找到它

      android:onClick="addItem"

需要删除的menu_main.xml文件