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 Basic Android Programming Initializing a Button

Luke Horvath
Luke Horvath
590 Points

Can not find symbol -> findViewbyId(R.id.showFactButton);

I am the complete objective task and I am following the instructions precisely and have tried many alternatives and triple checked spelling. I am using Android Studio 2.3.1 and there are significant differences between the video and current version and keeping up at times can be a little confusing.

Any help regarding this would be great

FunFactsActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FunFactsActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fun_facts);

        // Declare our View variables and assign them the Views from the layout file
        TextView factLabel = (TextView) findViewById(R.id.factTextView);
        Button factlabel = (Button) findViewbyId(R.id.showFactButton);
    }
}

1 Answer

Jason Wiram
Jason Wiram
42,762 Points

Hi, Luke Horvath . Looks like you have two errors.

In this line you you have your variable named factLabel instead of showFactButton (might have been a copy/paste error).

Button factlabel = (Button) findViewbyId(R.id.showFactButton);

Additionally, if you try to run your code you'll get an error regarding "findViewbyId." This should give you a hint to look closely at that method to see if something is wrong. In this case you'll find a simple typo. The "B" should be capitalized.

Luke Horvath
Luke Horvath
590 Points

I restarted the text multiple times and tried everything but on my final attempt, I just wrote it how I thought I had multiple times and then clicked preview. The code disappeared and I was left with a blank screen so I clicked check work and it said I completed it. Still confused as I thought I had done the same thing loads of times, maybe the site was bugging out :/