Skip to content

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

Description

@ivotai

自定义 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 加以区分后,报错不再复现。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions