今天在学的时候,遇到好多error, 红色的让人看着就烦、、、
1、 You must call removeView() on the child's parent first
我是因为添加了重复的view,删掉就解决了,还有其他的不错的解决方法案例 点我
2、error: No resource identifier found for attribute ‘**’ in package
检查一下自己的包,里面是否有还没定义的,引用包的两种方法
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/com.example.st.mytopbar"
3、R.styleable 无法找到,只能有R.style
在attrs.xml 中,查看是否已经建立方法,如下
<declare-styleable name="Topbar">
<attr name="title" format="string" />
</declare-styleable>
4、cannot resolve symbol ‘R’
一般是自动的,如果出现这种问题,可以在java文件夹里新建R.java文件,我最后是重新建立 module 解决的- -