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 (2014) Basic Android Programming Making a Button Do Something

Marcos Frutos
Marcos Frutos
1,291 Points

Cannot resolve Symbol 'TextView' / Cannot resolve Symbol 'Button'

TextView factLabel = (TextView) findViewById(R.id.factTextView);
Button myButton = (Button) findViewById(R.id.showFactButton);

The ID's of the Text and Button (R.id...) are correct, but when my mouse is over TextView or Button, it says: "Cannot resolve Symbol". Any solutions? Newbie in Android Development over here :P

Thanks!

PD: Here is the XML.

 <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="I am just so sexy lately."
        android:id="@+id/factTextView"
        android:textSize="24sp"
        android:textIsSelectable="true"
        android:textColor="@android:color/white"
        android:textAlignment="center"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="See more"
        android:id="@+id/showFactButton"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@android:color/white" />

1 Answer

Jeremy Faith
PLUS
Jeremy Faith
Courses Plus Student 56,696 Points

You may need to organize imports. Try hovering over TextView and then pressing ALT + ENTER. If in Eclipse you should be able to press CTRL + ALT + ENTER to organize imports.

Marcos Frutos
Marcos Frutos
1,291 Points

Dear God, I am embarassed!

Works like charm now. Thanks a lot!