Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBilly Lardizabal
5,017 Points@InjectView Not Working
In the current version 7 of Butter Knife, InjectView throws an error. However, when replacing the 7 with version 6, it works. Was just wondering if there was an updated method to go with Butter Knife 7.
4 Answers
Seth Kroger
56,413 PointsIt's renamed to @Bind as well as inject() to bind(). You can see the updated docs for the new version here: http://jakewharton.github.io/butterknife/
A lot of the annotations and functions were renamed in the jump from version 6 to 7 so it might be a better idea to use the same version Ben uses to avoid confusion.
Majdi Zrelli
Courses Plus Student 19,262 PointsIn addition import this element before replacing injectView and inject width Bind:
import butterknife.ButterKnife;
import butterknife.Bind;
Fidel Torres
25,286 PointsHello There
//This is the code are given in the Class Notes
@InjectView(R.id.timeLabel) TextView mTimeLabel;
@InjectView(R.id.temperatureLabel) TextView mTemperatureLabel;
@InjectView(R.id.humidityValue) TextView mHumidityValue;
@InjectView(R.id.precipValue) TextView mPrecipValue;
@InjectView(R.id.summaryLabel) TextView mSummaryLabel;
@InjectView(R.id.iconImageView) ImageView mIconImageView;
//And this is what should you use according to the update in the ButterKnife Library
@Bind(R.id.timeLabel) TextView mTimeLabel;
@Bind(R.id.temperatureLabel) TextView mTemperatureLabel;
@Bind(R.id.humidityValue) TextView mHumidityValue;
@Bind(R.id.precipValue) TextView mPrecipValue;
@Bind(R.id.summaryLabel) TextView mSummaryLabel;
@Bind(R.id.iconImageView) ImageView mIconImageView;
For more info check the Docs
Oussama DJEDIDI
4,599 PointsI think this last answer should marked as best answer for help