Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义View和主界面id冲突问题 #62

Open
ivotai opened this issue Mar 16, 2023 · 0 comments
Open

自定义View和主界面id冲突问题 #62

ivotai opened this issue Mar 16, 2023 · 0 comments

Comments

@ivotai
Copy link

ivotai commented Mar 16, 2023

自定义 View 里有个 MaterialTextView,id 是 tv。
主界面 Activity 布局中使用了上述自定义 View,且布局里本身有个 RTextView,id 也是 tv。

然后报错如下:
Caused by: java.lang.ClassCastException: com.google.android.material.textview.MaterialTextView cannot be cast to com.ruffian.library.widget.RTextView

猜测是 inflate 的过程中因为 id 一样 binding 错了。
修改自定义View中 id 为 ctv 加以区分后,报错不再复现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant