Android编程问题解决之Error should use android showAsAction
来源:互联网 发布:声音好听的网络男歌手 编辑:程序博客网 时间:2024/06/03 18:53
Android编程问题解决之Error should use android showAsAction when not using support library
在编写关于menus.xml文件时,可能会遇到错误提示Error should use android showAsAction when not using support library,这个问题是怎么出现呢?
从Android1.0到Android6.0增加了很多功能,为了让低版本的android系统可以使用最新的添加的功能,Android操作系统的编写者在最新的操作系统中会提供一个包(例如com.android.support:appcompat-v7:23.3.0就是Android6.0的低版本支持包),这个包用于让低版本的adnroid系统可以使用最新的功能。
如果在使用了包的android项目中使用了低版本支持包,在定义menu资源时应该使用如下形式
<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>
其中yourapp:showAsAction=”ifRoom”就是低版本支持包中提供的内容。
如果在项目中没有使用低版本支持包,在定义menu资源时应该使用如下形式
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search"android:showAsAction="ifRoom" /> </menu>
如果在编程中出现Error should use android showAsAction when not using support library错误只要按照下面的方法修改即可
1. 如果需要低版本支持包使用yourapp:showAsAction=”ifRoom” 方式
2. 如果不需要低版本支持包将低版本依赖去掉即可
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' //compile 'com.android.support:appcompat-v7:23.3.0'}
版权声明:原创作品版权归作者所有,转载请注明出处,未经允许禁止私自印刷及出版。一经发现作者将依法追究其法律责任。
与我联系:QQ群539225664
1 0
- Android编程问题解决之Error should use android showAsAction
- android:showAsAction
- android 开发之旅, should use @string resource警告
- android studio中使用menu之showasaction
- app:showAsAction 和android:showAsAction的区别
- [Android] hardcoded string should use @string警告
- should use @string resource / android 控件名称
- Android——showAsAction()
- Android-Menu-ShowAsAction
- android:showAsAction用法
- 关于android:showAsAction
- android studio 使用 showAsAction
- android:showAsAction 无效
- when not using the appcompat library, you should be using the android:showAsAction attribute.
- Android之Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE问题解决
- Android学习笔记之Menu的ShowAsAction属性的设置
- Android 开发 Tip 10 -- app:showAsAction & android:showAsAction
- app/android:showAsAction的区别
- Solr之搭建Solr6.0服务并从Mysql上导入数据
- 数据结构----直接插入排序
- 通过JAVASCRPIT给input【text】赋值
- MySQL入门——约束简介、外键约束说明、外键约束主表与子表的创建与使用约束案例
- 给图片设置小圆点
- Android编程问题解决之Error should use android showAsAction
- C++的函数的重载
- 【Java基础】基本类型与运算
- 多线程 - Callable接口
- HTTP状态码
- ORA-22992:无法使用从远处表选择LOB定位器
- linux Cent-OS 安装中文输入法
- 浅谈设计模式之观察者模式
- assignment,shallow copy,deep copy,引用,不可变对象