在我的 Activity 中,我使用两种 View :X 型和 Y 型。
X 类型 View 直接在我调用的 xml 布局文件中定义 setContentView()
.对于 Y 类型的 View ,它们出现在我在 Activity 中膨胀的对话框中,然后将其作为标题 View 添加到我的 ListView 中(在 Activity xml 中)。
现在,我如何使用 butterknife 来注入(inject)这两种 View 类型。如果我调用 Butterknife.bind(@NonNull Activity target)
,它只会注入(inject) Activity xml 中存在的那些 View 。如果我调用 Butterknife.bind(@NonNull Object target, @NonNull Dialog source)
,它只会注入(inject)该对话框中存在的 View 。
希望我已经清楚地解释了这个问题。
让我知道是否需要其他任何东西。
最佳答案
得到JW here的回复.
再次为他人陈述:
Create a view holder class for each layout and bind an instance of each individually. There's no way to support binding two layouts into one class.
关于android - Butterknife 将 View 绑定(bind)到不同的源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46956047/