Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9082877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:39:21+00:00 2026-06-16T20:39:21+00:00

I’m just starting out in android and I have my MainActivity class which has

  • 0

I’m just starting out in android and I have my MainActivity class which has a void in there ‘addItem’ which I want to move to a different class each time I delete the void the app force closes

How do I remove the void without it interfering with the operation of the app? I have searched the path of the project and cant find any references to it so I’m at a loss as to why it’s not working.

I’m using IntelliJ on windows 7 if that helps

*UPDATE*

A bit more detail, there isn’t much in the app at the moment; here is the 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) {



    }

I have created another class that is going to have the addItem void in it, but when I delete it from here and try to run the app it stops

Here is the logcat error

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:39:22+00:00Added an answer on June 16, 2026 at 8:39 pm

    Found it

          android:onClick="addItem"
    

    In the menu_main.xml file needed to be removed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which has BIG numbers and small numbers in it. I
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.