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
Jacob Montague
Courses Plus Student 681 PointsInitialize the getAnswerButton Varible
package com.example.crystal.ball;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Declare our view variables
TextView answerLabel = (TextView) findViewById(R.id.textView1);
Button getAnswerButton;
}
} Need help i dont know where to start on this code.
5 Answers
HELGA TANWANI
2,059 Points// what you need to do is find the button id and assign it to the AnswerButton variable. Thats what it means to initialize. For example:
Button AnswerButton = (Button) findViewById(R.id.button1);
// Not sure if that helps....let me know if that is what you needed. If not please explain in detail what lecture and where you need help.
Jacob Montague
Courses Plus Student 681 PointsThanks that's what i needed Thanks. By looking at how to do it from what you wrote helped showed me how to initialize it.
HELGA TANWANI
2,059 PointsI am glad I was of help. I would also suggest you get this book on how to program with Java by Deitel and Deitel. Also these free intro to java videos on youtube http://www.youtube.com/playlist?list=PL07BAEC9E3E9E49F3 will help as well. They will help you a bunch in your Android programming path and give you a good grasp of java and object oriented programming which will help you a lot in Android.
Jacob Montague
Courses Plus Student 681 PointsAlright Thanks i guess i have alot of watching to do.
HELGA TANWANI
2,059 PointsSure let me know if you need assistance