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 Setting Views with Data

Hi. Am trying to get text data from Movie, I think.

The given example wasn't so clear. Can you help me get movie data? Steve Hunter

MovieActivity.java
import android.os.Bundle;
import android.view.View;

public class MovieActivity extends Activity {

    @BindView(R.id.movieTitle) TextView mTitleLabel;
    @BindView(R.id.movieImage) ImageView mMovieImage;

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

        // The rest of the code is omitted for brevity :)
    }

    public void updateDisplay(Movie movie) {
        mTitleLabel.setText(movieTitle.getTitle());
    }
}

1 Answer

Hi Mal,

You've done the hard bit here; but got the instance of Movie incorrect. The Movie instance you want to use is the one passed into the updateDisplay() method. It is called movie, not movieTitle. You've correctly used that as a parameter for the setText method of the mTitleLabel.

So amend your code to use that instead; you'll end up with something like:

    public void updateDisplay(Movie movie) {    // <- use this movie
        // Add your code here!
        mTitleLabel.setText(movie.getTitle());
    }

Steve.

Woo hoo! I should stop smiling coz people will start asking what am I watching on my laptop, lol. This android is a tricky one.

Many thanks for your help. I've got years before I become a coding jedi as yourself.

:+1: