Reputation: 313
Add a second Toast notification that combines these two lines into one line (make sure you leave the first two lines intact!). For this second Toast, chain the
show()
method to themakeText()
method, and use whatever String message you want.
What's wrong with this?
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
allDoneToast.show();
Upvotes: 0
Views: 116
Reputation: 2900
It sounds like the point of the task is to combine those two lines into a single line of code by chaining methods together - neither solution is "wrong" or "right", I suspect they just want you to know you can do so.
You chain methods by calling one immediately on the result of the other, like this:
Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
Upvotes: 2
Reputation: 869
Nothing.
But there's no need to keep a reference to a allDoneToast
Toast object if you aren't going to use it afterwards. In this case, using a anonymous object makes a bit more sense, unless you have a good reason not to do so.
Upvotes: 1