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 Simple Android App (retired 2014) Getting Started with Android Adding an OnClickListener to a Button

No quick fix for answer.Label.setText(answer)

On the video it shows the quick fix coming up to make this string final, but I don't have that option. It's producing an error so I can't continue, any ideas?

'''Android //Declare our View variables TextView answerLabel = (TextView) findViewById(id.textView1); Button getAnswerButton = (Button) findViewById(R.id.button1);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {


        public void onClick(View v) {
            // The button was clicked, so update the answer label with an answer
        String answer = "Yes";
        answer.Label.setText(answer);

'''

1 Answer

This line

answer.Label.setText(answer);

should be

answerLabel.setText(answer);

If don't have show any options you can manual add final keyword to your variable such as

final TextView answerLabel = (TextView) findViewById(id.textView1);