September 2014
Beginner
286 pages
6h 16m
English
Another way to output text on the screen is using toasts. A toast is a simple message widget that can provide feedback about an operation in progress. It's a core Android widget, not an AndEngine component, but we can nevertheless use it in our game.
The easiest way to show a toast is to use a static method provided by the Toast class. In a general Android app, we can simply call this as follows:
Toast.makeText(activity, "Hello World", Toast.LENGTH_LONG).show();
We can also call a toast inside the activity itself. This can be done as follows:
Toast.makeText(this, "Hello World", Toast.LENGTH_LONG).show();
The makeText() method creates the Toast object. It takes three parameters: the context (activity), the text to show, and the length ...
Read now
Unlock full access