Android Studio dấu như lỗi dòng này:Tại sao mở rộng ImageView được đánh dấu là lỗi?
public class ParallaxView extends ImageView
Đây là lỗi:
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.
Nó khuyến cáo tôi để mở rộng AppCompatImageView
nhưng sau đó kiểm tra JUnit tôi không vượt qua vì AppCompatImageView
cần có một mô hình Context
với tài nguyên và Imageview
không cần điều này.
Ở đây vấn đề để giải quyết các vấn đề khác:
NullPointerException creating an AppCompatImageView with mock Context
Tôi có thể bỏ qua lỗi và sử dụng ImageView này? Bất kỳ giải pháp nào khác?