Difference between bind and injectView in butterknife
Asked Answered
B

3

7

I am using butterknife library. I don't know much about how to use it. I found injectView and bind doing the same thing but I am not really sure. Can anyone explain the difference between these two.

Buyer answered 1/2, 2016 at 4:40 Comment(0)
G
10

Can anyone explain the difference between these two ?

@InjectView was changed to @Bind .

Annotate fields with @Bind and a view ID for Butter Knife to find and automatically cast the corresponding view in your layout.

class YourActivity extends Activity {
  @Bind(R.id.TvTitle) TextView title;

Please check below links. Hope this helps .

  1. JakeWharton Butterknife
  2. The import butterknife.InjectView cannot be resolved

  3. Introduction Butter Knife

GRADLE

compile 'com.jakewharton:butterknife:7.0.1' //8.4.0 

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

Gillian answered 1/2, 2016 at 5:18 Comment(3)
One more thing. I am using android studio. Here its only showing @InjectView but not Bind.Buyer
@Bind(R.id.TvTitle) and ButterKnife.bind(this); #28139359Gillian
Oops! I was using version 5.x.x.Buyer
S
7

If I'm not mistaken, they have the same function. There was a change in naming convention starting version 7 of butterknife, injectView was changed to bind.

Check the changelog, also check this issue.

Check this link: How to use butterknife

Saturninasaturnine answered 1/2, 2016 at 5:13 Comment(0)
D
0

As of Version 8.0.0 @Bind becomes @BindView and @BindViews

Check the butterknife changelog for further information!

Dissection answered 7/2, 2018 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.