使用 Compat Lib 的 ICS 电话缺少溢出 ActionBar 条目
使用兼容库 r6。在 Galaxy Nexus (ICS) 上进行测试。
在清单中具有: android:minSdkVersion="13" android:targetSdkVersion="14"
菜单项定义为:
<item android:id="@+id/menu_search"
android:showAsAction="ifRoom"
android:actionViewClass="android.widget.SearchView" />
<item android:id="@+id/menu_refresh"
android:title="@string/refresh_menu"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="ifRoom"/>
在纵向中,操作栏具有搜索控件,但没有溢出操作栏菜单项。
在横向中,操作栏同时具有搜索控件和溢出操作栏菜单项(我没有得到令人失望的图标,因为有足够的空间)。
在 Honeycomb/ICS 平板电脑上,一切正常,获取我的搜索控件和图标条目。
是做错了什么还是这看起来像是兼容库中的错误?提前致谢。彼得.
编辑 1 - 更多信息和潜在解决方案 我忘记补充的是,在 onCreateOptionsMenu 中我取消了搜索控件的图标。如果我不取消图标,我会得到“刷新”菜单。因此,这现在有点有意义,尽管我仍然希望看到溢出操作条目,因为我无法从 UI 折叠搜索控件(因为没有关闭按钮)。
编辑2 好的,如果我强制刷新项始终位于操作栏上并重新排序,我就可以正常工作:
<item android:id="@+id/menu_search"
android:showAsAction="always"
android:orderInCategory="1"
android:actionViewClass="android.widget.SearchView" />
<item android:id="@+id/menu_refresh"
android:title="@string/refresh_menu"
android:icon="@drawable/ic_menu_refresh"
android:orderInCategory="0"
android:showAsAction="always"/>
Using compat lib r6. Testing on Galaxy Nexus (ICS).
Have: android:minSdkVersion="13" android:targetSdkVersion="14"
in manifest
Menu items defined as:
<item android:id="@+id/menu_search"
android:showAsAction="ifRoom"
android:actionViewClass="android.widget.SearchView" />
<item android:id="@+id/menu_refresh"
android:title="@string/refresh_menu"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="ifRoom"/>
In portrait the action bar has the search control but NO overflow action bar menu item.
In landscape the action bar has both the search control and the overflow action bar menu item (I don't get the icon which is disappointing as there is plenty of room for it).
On a Honeycomb/ICS tablet everything works perfectly, get my search control and an icon entry.
Am a doing something wrong or is this looking like a bug in the compat lib? Thanks in advance. Peter.
Edit 1 - Further Info and potential solution
What I forget to add is that in onCreateOptionsMenu
I de-iconify the search control. If I don't de-iconify I get the 'refresh' menu. So this is now sort of making sense although I would still expect to see the overflow action entry given that I cannot collapse the search control (as there is no close button) from the UI.
Edit 2
OK I can get this working if I force the refresh item to always be on the action bar and re-order:
<item android:id="@+id/menu_search"
android:showAsAction="always"
android:orderInCategory="1"
android:actionViewClass="android.widget.SearchView" />
<item android:id="@+id/menu_refresh"
android:title="@string/refresh_menu"
android:icon="@drawable/ic_menu_refresh"
android:orderInCategory="0"
android:showAsAction="always"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在溢出菜单中只有文本,因此您必须添加适当的标志:
In the overflow menu there's only text so you have to add the appropriate flag: