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 trialmike LaBianca
Courses Plus Student 2,456 Pointsthe showFactButton is highlighted red an wont let me run app need help, why is it red?
even when i copy an paste the code from the site its still red need help
3 Answers
Dhruv Gupta
4,320 PointsTwo potential things,
You haven't initialized a button like this. private Button showFactButton;
Or you haven't found the id
showFactButton = (Button) findViewbyId(R.id.showfactbutton);
Apart from that my guess is as good as yours
mike LaBianca
Courses Plus Student 2,456 Pointsthanks you helped me figure it out, i appreciate it
Angel Sosa
892 PointsHello guys, Im having this issue(.setOnClickListener is showing in red):
public class FunFactsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_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 v) {
//The button was clicked, so update the fact label with new fact
String fact = "Cristo es que salva!";
factLabel.setText(fact);
}
};
showFactButton.setOnClickListener(listener);
}
mike LaBianca
Courses Plus Student 2,456 Pointsmike LaBianca
Courses Plus Student 2,456 Pointsit says cannot resolve symbol