gpt4 book ai didi

java - 在 Android Studio 中导入 Butterknife 后注解 @InjectView 不工作?

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:25 25 4
gpt4 key购买 nike

最近刚接触到 butterknife。我在我的 gradle(module : app) 文件中添加了这一行:编译 'com.jakewharton:butterknife:7.0.1'

它同步没有任何错误。我可以将“butterknife.Butterknife”导入到我通常导入的类文件中。但是 cant import butterknife.InjectView 好像没有?有什么建议吗?

最佳答案

Butterknife 7.0.0 版本包含重命名注释动词的重大更改。这在变更日志中突出显示并反射(reflect)在网站中。

Version 7.0.0 *(2015-06-27)*
----------------------------

* `@Bind` replaces `@InjectView` and `@InjectViews`.
* `ButterKnife.bind` and `ButterKnife.unbind` replaces `ButterKnife.inject`
and `ButterKnife.reset`, respectively.
...

https://github.com/JakeWharton/butterknife/blob/f65dc849d80f6761d1b4a475626c568b2de883d9/CHANGELOG.md

一个非常好的、最新的用法介绍位于http://jakewharton.github.io/butterknife/

这是最简单的用法:

class ExampleActivity extends Activity {
@Bind(R.id.title) TextView title;
@Bind(R.id.subtitle) TextView subtitle;
@Bind(R.id.footer) TextView footer;

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_activity);
ButterKnife.bind(this);
// TODO Use fields...
}
}

关于java - 在 Android Studio 中导入 Butterknife 后注解 @InjectView 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31584583/

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