Android Studio中标记为错误这一行:为什么将ImageView标记为错误?
public class ParallaxView extends ImageView
在这里的错误:
This custom view should extend android.support.v7.widget.AppCompatImageView instead less... (Ctrl+F1)
In order to support features such as tinting, the appcompat library will automatically load special appcompat replacements for the builtin widgets.
However, this does not work for your own custom views. Instead of extending the android.widget classes directly, you should instead extend one of the delegate classes in android.support.v7.widget.AppCompat.
它建议我向AppCompatImageView
但后来我的JUnit测试不及格,因为AppCompatImageView
需要一个模拟Context
与资源和Imageview
不需要此。
这里解决其他问题的问题:
NullPointerException creating an AppCompatImageView with mock Context
我可以忽略此错误和使用ImageView的?其他解决方案?