gpt4 book ai didi

android - butterknife 中的 `@Bind` 和 `@BindView` 有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:52:59 27 4
gpt4 key购买 nike

我刚开始使用 butterknife。
在项目中,同事使用了butterknife,版本是7.0.0。

我看到他写了@Bind(R.id.tv_name)
但是我看到butterknife官网butterknife版本是8.0.1,语法是@BindView(R.id.tv_name)

语法有变化吗?或者两者都可以使用?还是别的?
它们之间有什么区别?

网上没找到答案
希望大家多多帮助,thx!

最佳答案

是的,语法在 8.0 版中发生了变化。

您可以在此处查看更新日志:https://github.com/JakeWharton/butterknife/blob/master/CHANGELOG.md#version-800-2016-04-25查看所有更改。但是从 7.X 到 8.X 的变更日志是:

  • @Bind becomes @BindView and @BindViews (one view and multiple views, respectively).
  • Calls to bind now return an Unbinder instance which can be used to null references. This replaces the unbind API and adds support for being able to clear listeners.
  • New: @BindArray binds String, CharSequence, and int arrays and TypeArray to fields.
  • New: @BindBitmap binds Bitmap instances from resources to fields.
  • @BindDrawable now supports a tint field which accepts a theme attribute.
  • The runtime and compiler are now split into two artifacts.
    compile 'com.jakewharton:butterknife:8.0.0'
    apt 'com.jakewharton:butterknife-compiler:8.0.0'

  • New: apply overloads which accept a single view and arrays of views.

  • ProGuard rules now ship inside of the library and are included automatically.
  • @Optional annotation is back to mark methods as being optional.

关于android - butterknife 中的 `@Bind` 和 `@BindView` 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37662171/

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