看截图箭头所指的属性,是使用了自定义属性。为什么要使用自定义属性,而不是用android:showAsAction 属性

这是因为你使用了 support library 库的属性,因为support library 中的一些属性,比如 android:showAsAction 属性,

在老设备的Android Framework 中就不存在这个属性,所以为了在老设备中使用这些的新的属性就必须自定义名称空间,

如果你是基于Android 3.0 及以上版本开发 就不需要使用support library,也就不存在现在所描述的问题了,

可以直接使用 android:showAsAction 属性来实现添加操作项

下面是官方的原文解释:

Using XML attributes from the support library

Notice that the showAsAction attribute above uses a custom namespace defined in the<menu> tag. This is necessary when using any XML attributes defined by the support library, because these attributes do not exist in the Android framework on older devices. So you must use your own namespace as a prefix for all attributes defined by the support library.

更多相关文章

  1. Android复合文本SpannableString使用总结
  2. [Android] 内存泄漏调试经验分享 (一)
  3. Android中使用硬盘模拟SD卡
  4. Android第三方库
  5. 深入解析_Android的自定义布局
  6. Android开发周报:Android将使用OpenJDK、React Native详解
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. android输入法02:openwnn源码解析01—输入
  2. Linux 安装android
  3. Android HIDL学习(2) ---- HelloWorld
  4. 百度的Android招聘面试题
  5. Android 工具之hierarchyviewer
  6. Android客户端连接Struts2服务器,连接不上
  7. Android(安卓)Audio代码分析9 - AudioTra
  8. Android(安卓)Context getSystemService
  9. Android小项目之--电话与短信服务(附源码)
  10. 【多端应用开发系列1.1.1 —— Android:使