我希望做一个自定义的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'
这是什么原因?在线等待

解决方案 »

  1.   

    这个是在android2.2里面吗?
    当初我也遇到过这个问题,最后放弃用自定义了!
      

  2.   

    原因1,在自定义的view中没指明属性的用法 TypedArray typeArray = context.obtainStyledAttributes(attrs,
                    R.styleable.xxx);
    原因2:包名写错,多写或漏写
      

  3.   

    attrs.xml  这个文件 你放在哪个目录下了
      

  4.   

    错误原因: xmlns:ptr="http://schemas.android.com/apk/res/com.ycii.newseye.ui"
    解决方式:
    xmlns:ptr="http://schemas.android.com/apk/res/com.ycii.ljapp.ui",
    com.ycii.ljapp.ui为AndroidManifest.xml 中定义的 package,即: <manifestxmlns:android="http://schemas.android.com/apk/res/android"  package="com.ycii.ljapp.ui"
    android:versionCode="1"     
    android:versionName="1.0" >