Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App (2014) Testing and Debugging Making a Toast

Maksims Visnakovs
Maksims Visnakovs
2,616 Points

Build a Simple Android App

Hi there. I have difficulty in solving the Toast problem. in task 3 out of three I have to add a Second toast which I have create out of two lines I have created in two previous tasks and make it a one line. I don't really understand how is this possible and can't think about a solution due to my limited JAVA knowledge. If someone knows the answer will be appreciated.

Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);
Toast.makeText(this,"All done!",Toast.LENGTH_LONG).show();
Toast allToast = Toast.makeText(this,"Great!",Toast.LENGTH_LONG).show();

1 Answer

Kevin Faust
Kevin Faust
15,353 Points

This is the first part which I believe you got:

Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);

For the last challenge, you dont create a variable for your toast but rather just create a toast and display it.

Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();

You got it correct in your code on the second line. Your third line won't work because you cant show a toast and store it as a variable. Only if you dont show it then it would work