attribute 的名字重复的问题
来源:互联网 发布:js 汉字长度 编辑:程序博客网 时间:2024/05/13 00:57
如果从单独开发app的话,可能不会遇到多个自定义类的attribute 的名字重复的问题。但是如果是团队合作开发的话,可能会碰到这样的问题,A和B自定义的两个类都用了同一个名字来定义属性,这时系统会报出警告,Attribute "xxx" has already been defined. A和B又都不想修改自己的名字,这时就很头痛。
下面举个例子,在values文件夹下定义一个上面的attrs.xml的文件,eclipse即会报错:Attribute "icon" has already been defined。因为在PreferenceHeader, Preference两个属性集里定义了两个相同的属性。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<? xml version =
"1.0"
encoding =
"utf-8"
?>
< resources >
< declare-styleable name=
"PreferenceHeader"
>
<!-- Identifier value
for
the header. -->
< attr name=
"id"
format =
"integer"
/>
< attr name=
"icon"
format =
"integer"
/>
<!-- The fragment that is displayed when the user selects
this
item. -->
</declare-styleable >
< declare-styleable name=
"Preference"
>
< attr name=
"icon"
format =
"integer"
/>
<!-- The key to store the Preference value. -->
< attr name=
"key"
format =
"string"
/>
</declare-styleable >
</ resources >
解决方案:
1.在xml文件里前面先声明属性
2.然后在属性集合里引用声明的属性即可。
以上面的文件为例来修改,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<? xml version =
"1.0"
encoding =
"utf-8"
?>
< resources >
< attr name =
"icon"
format =
"integer"
/>
< declare-styleable name=
"PreferenceHeader"
>
<!-- Identifier value
for
the header. -->
< attr name=
"id"
format =
"integer"
/>
< attr name=
"icon"
/>
<!-- The fragment that is displayed when the user selects
this
item. -->
</declare-styleable >
< declare-styleable name=
"Preference"
>
< attr name=
"icon"
/>
<!-- The key to store the Preference value. -->
< attr name=
"key"
format =
"string"
/>
</declare-styleable >
</ resources >
0 0
- attribute 的名字重复的问题
- ResourceManager的名字问题
- 多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- 【android】多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- 多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- 多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- 【android】多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- 【转】多个类定义attr属性重复的问题:Attribute "xxx" has already been defined
- input 标签 的名字问题
- 预编译文件的名字出现重复了,错误
- 防止重复的item name,自动修改名字
- 关于c++名字解析的一个问题:名字空间污染
- Attribute names cannot contain colons jdom生成带有名字空间的xml元素
- 解决smarty的 invalid attribute name 问题
- Firefox中获取Attribute的问题
- struts2的Action名字的大小写问题
- 重复提交的问题
- 重复定义的问题
- 【matlab函数】——str2func函数的使用
- pixhawk 光流--位置估计--姿态估计--位置控制--姿态控制
- Android之OnClick事件监听
- 【Leetcode】Count Primes
- oracle查看和修改最大连接数
- attribute 的名字重复的问题
- 判断网络状态
- 深度学习系列文章之一:电脑配置选择
- 文档化说明的重要性
- laravel学习随记1
- 图的广度优先搜索(采用邻接表存储方式)
- CityMaker学习教程10 示例代码的使用Javascript
- Struts2找不到action报404错总结,3个解决方法
- 二、C++ 访问类的成员函数和成员变量的三种方法