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 trialEmmancipate Musemwa
291 PointsMy data types are in Red
I am following android app development tutorial, everything is working fine so far. The problem is in java, my data types are in red and the import statements are different from the ones shown in the tutorial '''package nf.co.emancode.funfacts;
import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
public class FunFactsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
//Declare our View variables
TextView factLabel;
Button showFactButton;
} '''
TextView and Button are in red
1 Answer
Stone Preston
42,016 Pointsyou will need to import the TextView and Button classes manually. add the following to your list of import statements at the top of your file:
import android.widget.Button;
import android.widget.TextView;
Whenever you type out a class name, be sure and choose it from autocomplete. When you choose the class from autocomplete, it automatically gets imported. In your case you chose to just type it out fully, and doing so caused the class to not get imported automatically.
Emmancipate Musemwa
291 PointsEmmancipate Musemwa
291 PointsThanks a lot it worked