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 trial

Android Build a Weather App (2015) Hooking Up the Model to the View Using Butter Knife for Views

Shagun Goel
Shagun Goel
2,297 Points

Injecting TextView error

./MovieActivity.java:15: error: annotation type not applicable to this kind of declaration @InjectView(R.id.movieTitle) TextView mTitleLabel;

Not entirely sure why I'm getting this error.

MovieActivity.java
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.ImageView;

public class MovieActivity extends Activity {

// @InjectView here  ... 

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_movie);

        ButterKnife.inject(this);

        @InjectView(R.id.movieTitle) TextView mTitleLabel; // not here!
        // The rest of the code is omitted for brevity :)
    }
}

1 Answer

Hi Shagun,

You want to put the @InjectView outside of onCreate - I've added a comment in your code.

Steve.

Shagun Goel
Shagun Goel
2,297 Points

Ah yes of course! Thank you for your help! :D

Hey, no problem! :-)