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 trialNatansh Pandya
2,810 PointsError on setOnClickListener
Error message: The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new OnClickListener(){})
getAnswerButton.setOnClickListener(new view.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String answer="yes";
answerLable1.setText(answer);
}
2 Answers
Liam Peters
8,792 PointsHi Natansh! from your code snippet I can see you are using the lowercase V version of View. We need to use the uppercase version to get the correct answer!
Also I assume you've closed your curly braces, bracket and delimited (This -> });
) at the end of your getAnswerButton.setOnClickListener declaration!
Hope that Helps!
Natansh Pandya
2,810 PointsIts working now. Thanks a lot.