showAsAction
must be in a different namespace ( yourapp
in the example below).
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yourapp="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" yourapp:showAsAction="ifRoom" /> ... </menu>
youapp
is just a namespace identifier that points to the http://schemas.android.com/apk/res-auto
namespace, you can change it to anything. The SDK automatically maps this namespace to your package name (see the list of changes below).
Added support for custom views with custom attributes in libraries. Custom attribute layouts should use the http://schemas.android.com/apk/res-auto namespace URI instead of the URI, which includes the application package name. This URI is replaced by the application defined at build time.
This is necessary to correctly search for attributes that are not available in previous versions of the OS, and are also part of your application package. Note from the documentation :
Note that the showAsAction attribute above uses its own namespace defined in the tag. This is necessary when using any XML-code attributes defined by the support library, since these attributes do not exist in the Android platform on older devices. Therefore, you should use your own namespace as a prefix for all attributes defined by the library support.
source share