gpt4 book ai didi

android - 类中没有 View 的 ButterKnife 7.0 BindString

转载 作者:行者123 更新时间:2023-11-29 20:37:22 27 4
gpt4 key购买 nike

我在没有任何 View 的辅助类中使用 ButterKnife 7.0 中的 @BindString。

Butter Knife 的绑定(bind)方法是:

bind(Activity target)
bind(View target)
bind(Dialog target)
bind(Object target, Activity source)
bind(Object target, View source)
bind(Object target, Dialog source)

如您所见,没有任何方法可以让我在没有 View 对象的情况下进行绑定(bind)。

我可以获得任何 Activity 并将其传递给类以进行绑定(bind),但这是 hacky 并且会向我的类添加不必要的依赖。

有什么方法可以在没有 View 的情况下使 Butter Knife 绑定(bind)?

最佳答案

要访问(字符串)资源,您需要一个ContextView 具有对创建它的 context 的引用。

我不知道如何在没有 context 的情况下绑定(bind)字符串。

更新:参见 this issue on Github

关于android - 类中没有 View 的 ButterKnife 7.0 BindString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31349881/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com