Android Toast Tutorial

What is Android Toast? The Android Toast is a view containing a quick little message for the user. When the toast is shown to the user, appears as a floating view over the application so it will never receive focus. The idea is to be as unobtrusive as possible, for example you want to instantly display information to user while they are using the your app. This tutorial will show you how to create a simple Android Toast using the toast class.

Android Toast Tutorial
I feel hungry now. :))
package com.example.AndroidToastTutorial;

import android.os.Bundle;
//import the toast widget
import android.widget.Toast;

public class AndroidToastTutorial extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        //"This is the Toast message" will appear when you run this code
        Toast.makeText(getBaseContext(), "This is the Toast message", Toast.LENGTH_SHORT).show();

The output of this code will look like the lower part of the image above (below the android logo and toasted bread). More info here. So that’s it! :)


One response to “Android Toast Tutorial”

Leave a Reply

Your email address will not be published. Required fields are marked *