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 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 {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_the_most_realistic_facts);
        //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,119 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.

YES THANK YOU!