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 Build a Simple Android App (2014) Basic Android Programming Accessing Views in Code

How do i get my Imports to have TextView and Button?

I have this problem that TextView and Button are not an import. Pls help

I suspect that you don't have the proper import statements at the top of your java class file, but it's hard to say without seeing your entire class.

It'd be a lot easier to see what's going wrong if you pasted some of your code here, or uploaded the entire project onto a site like github. Let me know if you can do that, and then I can be of some more assistance.

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class TheMostRealisticFacts extends ActionBarActivity {

    protected void onCreate(Bundle savedInstanceState) {
        //Declare our Views Variables and assign them the Views from the Layout file
        TextView FactLabel = FindViewByID;
        Button showFactButton;

2 Answers

Jacob Bergdahl
Jacob Bergdahl
29,118 Points

If the word TextView and Button is in red, place your cursor on them and hit ALT+ENTER. Next, select the top option. They have now been imported.