0

I've been trying to add a menu to my android application and it's not working. When I click the the 'Menu' button, the application stops working. This is my options_menu.xml file:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

  <item 
    android:title="Profile"
    android:id="@+id/menu_profile"/>

  <item 
    android:title="About"
    android:id="@+id/menu_about"/>

</menu>

This is my OptionsMenu.java class:

package com.carpool.jad;

import android.app.ListActivity;
import android.view.Menu;
import android.view.MenuInflater;

public class OptionsMenu extends ListActivity{

@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);
    return true;
}

}

This is my error log:

04-21 13:22:09.389: D/skia(1365): --- decoder->decode returned false

04-21 13:22:09.389: D/AndroidRuntime(1365): Shutting down VM

04-21 13:22:09.401: W/dalvikvm(1365): threadid=1: thread exiting with uncaught exception (group=0x40a70930)

04-21 13:22:09.479: E/AndroidRuntime(1365): FATAL EXCEPTION: main

04-21 13:22:09.479: E/AndroidRuntime(1365): android.view.InflateException: Binary XML file line #17: Error inflating class com.android.internal.view.menu.ExpandedMenuView

04-21 13:22:09.479: E/AndroidRuntime(1365):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.view.menu.ListMenuPresenter.getMenuView(ListMenuPresenter.java:99)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow$PanelFeatureState.getListMenuView(PhoneWindow.java:3417)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow.initializePanelContent(PhoneWindow.java:1130)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:578)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:847)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1520)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1854)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3701)

04-21 13:22:09.479: E/AndroidRuntime(1365):     at   android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3651)
stinepike
  • 54,068
  • 14
  • 92
  • 112
Jad
  • 115
  • 2
  • 5
  • 10

3 Answers3

0

According to this guide there is no need to call super.onCreateOptionsMenu(menu) when you override that function.

Try to remove that line and see if it works.

Also, check this post it might be your issue: Android: What could cause an Options Menu inflation error?

Community
  • 1
  • 1
tbkn23
  • 5,205
  • 8
  • 26
  • 46
  • I tried removng the line, and that's not the issue. Thanks for the link i will check it out – Jad Apr 21 '13 at 14:02
0

I created another project and copy/pasted all my code from the old one to the new one and it worked. Don't know what the error could have been. Thanks for the help guys.

Jad
  • 115
  • 2
  • 5
  • 10
0

Are you using a theme who parent is "android:Theme.Material"? Try to change to "Theme.AppCompat", even if your theme is on values-v21.

Rafa Araujo
  • 314
  • 1
  • 2
  • 9
  • i'm sorry, but this really fix a problem that i had here, and is just like the author asked, even the stacktrace. – Rafa Araujo Feb 26 '15 at 12:17