[扩展Android视图时为InflateException

问题描述 投票:0回答:1

我最近在尝试创建扩展AndroidX的AppCompatImageView的自定义类时遇到异常。

android.view.InflateException:{package}中的二进制XML文件行#9:layout / all_message_row:二进制XML文件行// {package}中的#9:layout / all_message_row:夸大类{package} .ui.view.DotImageView

时出错

我在该项目中使用视图绑定,并且只要您为视图充气,就会发生这种情况,例如:

AllMessageRowBinding.inflate(layoutInflater, parent, false)

这是类声明:

class DotImageView(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: androidx.appcompat.widget.AppCompatImageView(context, attrs, defStyleAttr) {
    // rest of the class logic here
}
android kotlin exception imageview inflate-exception
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.