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
Gytis Apanavičius
485 PointssetOnClickListener crashes my app
so whenever I try to use setOnClickListener method my app crashes.
protected void onCreate(Bundle savedInstanceState) { Answer mAnswer = new Answer(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView answerLabel = (TextView) findViewById(R.id.textLabel); Button askButton = (Button) findViewById(R.id.answerButton); askButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub
}
});
}
The only part of code that was edited. I also deleted some parts of code as shown in "Crystal Ball" project. But it doesn't work without them. I'm certain that it's that part which breaks my program, because I tried to run my app without it and it worked.
1 Answer
Erin Kabbash
5,210 PointsThis code looks ok.. Can you post the code for the rest of the class? Or maybe run it and see what error LogCat spits out and post that for us.