0
votes

I am trying to create Menu in res/menu

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    >
<item
    android:id="@+id/menu_item_new_crime"
    android:icon="@android:drawable/ic_menu_add"
    android:showAsAction="ifRoom|withText"
    android:title="@string/Add" />
    </menu>

I got error saying ifRoom|withText needs http://schemas.android.com/apk/res-auto I added that

<?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:android="http://schemas.android.com/apk/res-auto"
    >
   <item android:showAsAction="always"
       android:title="@string/Add"
       android:id="@+id/menu_item_new_crime"/>
</menu>

I got an error saying I needed to add title which I already have? I am not sure what the problem is. Any help would be appreciated.

2

2 Answers

1
votes

try change your code to this

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >

<item app:showAsAction="ifRoom|withText"
   android:title="@string/Add"
   android:id="@+id/menu_item_new_crime"/>
</menu>
1
votes

change your

xmlns:android="http://schemas.android.com/apk/res-auto"

to

xmlns:app="http://schemas.android.com/apk/res-auto

and

android:showAsAction="always"

to

app:showAsAction="always"