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 trialUmair Khalil
5,285 PointsfindViewById() isn't working!
When I try to us the findViewById() i get an error message that says im missing the method body, but in the video he doesn't create a method body please help!
3 Answers
Miles Torres
2,316 PointsYou could try and clean the project. I had the same problem. And if that doesn't work, try rebooting your computer.
Umair Khalil
5,285 PointsHere is my code Kourosh Raeen :
package com.example.diaded.funfactsproject;
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Button; import android.widget.TextView;
public abstract class FunFacts extends AppCompatActivity { //Declaring our view variables private TextView mFactTextView; private Button mShowFactsButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
}
//Assign the views from the layout file to the private fields declared
mFactTextView = (TextView)findViewById(R.id.factTextView);
Kourosh Raeen
23,733 PointsI'm not sure if your problem is related to this, but how come you've declared the class as abstract? Also, in the videos the class is named FunFactsActivity. Of course, you can name it anything you want, but make sure it is consistent with the rest of your code and is not a typo.
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsCan you post the complete line of code?