[英]Call requires API level 21 (current min is 19): android.view.View()
So I want to create a library that use custom view.所以我想创建一个使用自定义视图的库。 I want to inherit View class, but it's error because my minsdk is 19. I need my library to support sdk 19. Is there a way to solve this?
我想继承View类,但是报错,因为我的minsdk是19。我需要我的库来支持sdk 19。有没有办法解决这个问题?
class Dummy() : View(context, attrs, defStyleAttr, defStyleRes) {
You should use another constructor for this.您应该为此使用另一个构造函数。 The one you used is available only from the API 21.
您使用的那个只能从 API 21 中获得。
For custom views I use it like this:对于自定义视图,我像这样使用它:
class Dummy @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: View(context, attrs, defStyleAttr)
So 2 things here:所以这里有两件事:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.