Thursday, February 05, 2009
Minimal code to display a Toast message in Google Android
Toast is a widget to display an informational message to a user whilst they may well be doing something else. I find it useful for debugging on a real device to tell me something internal to the application has been fired. Afterwards I can just strip such things out of the build.
I find the
There is a
// show the frost pist message using the Toast widget Toast toast = Toast.makeText(context, "Woo hoo, toast", Toast.LENGTH_LONG); toast.show();
I find the
context
is normally part of the method signature. Toast.LENGTH_LONG
keeps the message up for a few seconds.There is a
Toast.LENGTH_SHORT
if you don't want the message to hang about for too long.Labels: google android
Subscribe to Posts [Atom]