Available for download on Wrox.com
Context context = getApplicationContext(); String msg = "To the bride and groom!"; int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, msg, duration); int offsetX = 0; int offsetY = 0;
toast.setGravity(Gravity.BOTTOM, offsetX, offsetY);
When a text message just isn't going to get the job done, you can specify a custom View or layout to use a more complex, or more visual, display. Using setview on a Toast object, you can specify any View (including a layout) to display using the transient message window mechanism.
For example, Listing 9-16 assigns a layout, containing the CompassView widget from Chapter 4 along with a Textview, to be displayed as a Toast.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.