I've got the following layout xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<item android:id="@+id/descriptions_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:icon="@drawable/ic_menu_info_details"
android:title="Toggle Descriptions On/ Off" />
<item android:id="@+id/settings_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:icon="@drawable/ic_menu_preferences"
android:title="Settings" />
But I keep getting this error: The required layout_width and layout_height attributes are missing
This is reported on lines 2, 9, 10. It seems totally bizarre. It's in an old project (>5 years) that I'm trying to resurrect.
i think menu
layout is not valid in res/layout
, you need to place it in res/menu
as stated in the documentation
To define the menu, create an XML file inside your project's res/menu/ directory and build the menu with the following elements
and you can inflate it using MenuInflater.inflate()
If this is the menu file then you have to close the menu tag at the end of file, Make sure this file is in res > menu folder > menu file.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<item android:id="@+id/descriptions_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:icon="@drawable/ic_menu_info_details"
android:title="Toggle Descriptions On/ Off" />
<item android:id="@+id/settings_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:icon="@drawable/ic_menu_preferences"
android:title="Settings" />
</menu>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With