Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Problem rebuilding the Fun Facts App, when adding the class FactBook ?

Hi I am rebuilding the app using my own facts and colors. All was going well until I reached the part where you add the Class FactBook, as shown in the video below.

http://teamtreehouse.com/library/build-a-simple-android-app-new/improving-our-code/simple-refactoring-using-a-class

When I hover over it it gives me the error 'Cannot resolves symbol FactBook'. I have rebuilt the app and cleaned it. I also restarted Android Studio. What do you guys think the problem can be? Thanks in advance.

4 Answers

If you could give us the snippit of the code, it would help greatly! :) I may know a few solutions if I can get a look at it.

Okay I figured out the problem. I did create the FactBook calss file but, I created it under the wrong folder. I corrected this by creating it under the right folder, duplicating the code then deleting the first FactBook file that I created in the wrong folder.

Okay does this help :

public class InterestingFactsActivity extends Activity { private FactBook mFactBook;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_interesting_facts);

    //Declare our View variables and assign the views from the layout file.
    final TextView factLabel = (TextView) findViewById(R.id.FacttextView) ;

    Button showFactButton = (Button) findViewById(R.id.ShowFactButton);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {


            //Update the label with our dynamic fact.
            factLabel.setText("");

        }
    };

    showFactButton.setOnClickListener(listener);
}

Could you post your FactBook class as well? The declaration mentioned by Kate is correct, and if that gave you an error, it must be within the FactBook class.

Kate Hoferkamp
Kate Hoferkamp
5,205 Points

Try adding this to your declaration.

private FactBook mFactBook = new FactBook();

I did as you suggested now both FactBooks are giving the same error message.