您的位置:首页 > 移动开发 > Android开发

action button" android:showAsAction" not work

2014-07-14 17:44 351 查看
If your app is using the Support Library for
compatibility on versions as low as Android 2.1,

the
showAsAction
attribute
is not available from the
android:
namespace.
Instead this attribute is provided by the Support Library and you must define your own XML namespace and use that namespace as the attribute prefix. (A custom XML namespace should be based on your app name, but it can be any name you want and is only accessible
within the scope of the file in which you declare it.)

For example:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
yourapp:showAsAction="ifRoom"  />
...
</menu>

好吧~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐