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

answerLable symbol can not be found

hey,

im having an issue with the answerLabel in the crystal ball videos. in the video it says put final at the public void part however, that dosent work for me i still get an error saying can not find symbol. any help would be great

thanks,

P.s i cant use eclipse (long story) and im using Android Studio

(```

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

 //Declare the view variables, assigns them to the layout file
    TextView answervariable = (TextView) findViewById(R.id.textView1);
    Button getAnswerButton = (Button) findViewById(R.id.button1);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //Button was clicked so update the answer label by providing a new answer
            String answer = "Yes!";
               answerLabel.setText(answer);
        }
    });

***)

1 Answer

Hi Gary,

By looking at the code snippet, i see that you've declared TextView variable answervariable and you are not using it inside onClickListener, instead you are using answerLabel which you didn't declare it at all, maybe that's the reason it's showing you "answerLable symbol can not be found"

Instead of doing it like this

answerLabel.setText(answer);

You can replace with the following code:

answervariable.setText(answer);

Hope this helps. Abdalla.

Ah yeah thanks that sorted it :)