- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个奇怪的问题,我在我的 android 应用程序中使用 menu.xml 文件,如下所示:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_refresh"
android:orderInCategory="100"
android:title="@string/action_refresh"
android:icon="@drawable/toc"
compat:showAsAction="always"/>
</menu>
它运行良好,但几天前我将我的 eclipse 更新到最后一个版本,之后,app:showAsAction="always"显示错误:
Should use android:showAsAction when not using the appcompat library and after that my action bar icons was moved to the overflow bar and not showing the in the action bar at all.
无论如何,appcompat 库是我的基本样式的父级。我应该怎么做才能解决这个问题?
最佳答案
你需要做三件事-
添加这三样东西xmlns:tools="schemas.android.com/tools"
给您的
tools:context="com.example.sample.YourActivity" xmlns:yourapp="http://schemas.android.com/apk/res-auto"<menu>
标记
连同通常的 xmlns:android="http://schemas.android.com/apk/res/android"
添加 yourapp:showAsAction="ifRoom"
给您的<item>
.
最后,通过 Project -> Clean...
最后一步为我解决了这个问题。只需清理项目(它们有时会变得很脏)
这是最终代码的样子:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="schemas.android.com/tools"
tools:context="com.example.sample.YourActivity"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_share"
android:orderInCategory="100"
android:title="Share"
android:icon="@drawable/ic_share_white"
yourapp:showAsAction="ifRoom" />
</menu>
关于android - 应该使用android :showAsAction when not using the appcompat library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26889976/
我正在构建一个 Android 应用程序,并希望在 actionBar 上始终显示一个按钮。我关注了this指南和其他人,但他们似乎都没有解决我的问题(尽管我猜他们非常接近......)。 我有包“a
我的应用程序操作没有显示为图标,我已经被困了很长时间,最后我意识到有些有标签 app:showAsAction="always" 而另一些有 android:showAsAction="always"
我在菜单中有项目,这是其中之一 我的菜单是这样的... 但我希望图标像这个菜单一样显示 有人可以帮忙吗? 最佳答案 尝试像下面这样膨胀你的菜单项,它对我有用: @SuppressLint(
我有一些反编译的代码,我正试图找出与常量值一起出现的常量名称。在我的一个 xml 文件中,我看到 app:showAsAction="2"。看起来,according android , 这可以取值
我有一个关于“android:showAsAction”的问题。我有一本适用于 Android 的书,在那本书中(IMO 它不是最新的,但大多数东西都是有效的)他们使用 android:sho
切换到工具栏后,菜单图标出现问题。虽然我设置了一个菜单项 android:showAsAction="always"它不显示图标,我只能点击弹出图标找到它。 这是我的 Activity public
我正在使用工具栏并使用相应操作的选项。我的问题是我想在工具栏上用白色显示“保存”文本,我应用了很多样式但它总是显示为黑色。 But when option appear as popup then t
我在运行时添加了一个 SubMenu,一切正常。我只是有一个问题:如何在运行时添加的 SubMenu 上设置 showAsAction="always"?没有实现这一点的方法,如果不设置它,我找不到任
我使用“最低要求的 SDK”API 11 创建了一个基本项目来测试 Action Bar。他们没有在栏上显示操作按钮,而是在操作溢出中结束,甚至栏是空的。我使用了以下代码。 但是当我添加以下命名空间
尝试在我的项目中实现操作栏时出现以下错误。我对 Action Bar 了解不够,有人可以给我一些帮助链接 我的 list
我正在尝试让 ActionBar 在我的应用程序上正常工作(我正在使用 ActionBarSherlock 在 Android 2.x 和 4.x 之间获得统一的 UI)。 我觉得 android:s
我想使用 Espresso 单击以下菜单项: 由于 ifRoom,在某些设备中,菜单在操作栏中显示为图标,而在较小的设备中,它显示在“更多选项”下。 我可以使用以下代码点击操作栏中的“保存”图标:o
我是 Android 的新手,遇到了一个似乎很常见的问题。没有一个解决方案对我有用,所以我不知道出了什么问题。 我有一个包含 2 个项目的菜单(搜索、购物),我希望搜索出现在操作栏中。但是,app:s
关于我的问题有很多问题,但我相信我正在遵循这些答案,但当我启动应用程序时,我的项目仍然不可见(它在溢出菜单下)。 这是我的 menu.xml ... MainActivity 扩展了 Ac
这个问题在这里已经有了答案: Items not showing in the ActionBar with showAsAction=“always” (1 个回答) 关闭 5 年前。 我正在使用
我有一个几乎是空的 android 项目,它使用了 appcomat。 我有一个需要始终隐藏的菜单项(仅在单击时显示在下拉列表中) 它在我的 Nexus7 上按预期工作,但在 Galaxy
我想知道,是否有人可以帮助我解决以下问题: 行 compat:showAsAction="always"不起作用,它被忽略了。我在 fragment 中使用它,更具体地说,我
我试过设置: android:showAsAction=".." 对于其中的每一个: ifRoom, never, withText, always, collapseActionView 但我总是得
我正在尝试使用以下代码将 SwitchCompat 添加到溢出菜单: main.xml menu_item_switch 的布局是: 如果我执行 app:show
我正在寻找 mentuItem.setShowAsAction() 的补充方法,即 menuItem.getShowAsAction(),因为似乎没有。 http://developer.androi
我是一名优秀的程序员,十分优秀!