class 中没有视图的 ButterKnife 7.0 BindString

ButterKnife 7.0 BindString in class that don't have a View

我在一个没有任何视图的助手 class 中使用来自 ButterKnife 7.0 的 @BindString。

Butter Knife 的绑定方法是:

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 对象的情况下进行绑定。

我可以获取任何 activity 并将其传递给 class 以进行绑定,但这是 hacky 并且会为我的 class 添加不必要的依赖项。

有什么方法可以让 Butter Knife 在没有 View 的情况下绑定?

要访问(字符串)资源,您需要 ContextView 引用了创建它的 context

我不知道如何绑定没有 context 的字符串。

更新:见this issue on Github