首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

自定义控件No resource identifier found for attribute 'who' in package,该怎么解决

2013-10-16 
自定义控件No resource identifier found for attribute 'who' in package我希望做一个自定义的

自定义控件No resource identifier found for attribute 'who' in package
我希望做一个自定义的BUTTON,首先在attrs.xml中定义了
<declare-styleable name="MyButton">
       <attr name="who" format="string" />
</declare-styleable>

多加了一个who属性

然后在main.xml中,
加命名空间了xmlns:t=" http://schemas.android.com/apk/res/com.limaoyuan.button"

然后在定义Button的地方
<com.limaoyuan.button.MyButton
    t:who="aaad"/>
报No resource identifier found for attribute 'who' in package 'com.limaoyuan.button'


这是什么原因?在线等待
[解决办法]
这个是在android2.2里面吗?
当初我也遇到过这个问题,最后放弃用自定义了!
[解决办法]
理论上应该没错的额。 具体原因就不清楚了。
[解决办法]
原因1,在自定义的view中没指明属性的用法 TypedArray typeArray = context.obtainStyledAttributes(attrs,
                R.styleable.xxx);
原因2:包名写错,多写或漏写
[解决办法]
attrs.xml  这个文件 你放在哪个目录下了。。。

热点排行