Toast Example in Android

Toast is the small notification popup for the user. Toast can be used to display information for the short period of time and disappears after little time. There is a no interaction of toast in main user thread.

The android.widget.Toast class is the subclass of java.lang.Object class. You will also able to create custom Toast in android. Toast have main method makeText() with three parameters. First Application Context,second one text message and last one time duration.  Let’s see simple code of Toast.

MainActivity.java

our xml file : activity_main.xml

For custom toast we have to make simple layout, which is below.

custom_toast.xml

In Java code there is setOnClickListener() is event listener for button. Every view have their own listener. You can get more information about event listener from here. Well, we have done our code. Run Project and your output look like below..!
android-toast-example-skynils

Download Project.

downlod

Now see next Tutorial Custom Font in Android.

(Visited 590 times, 1 visits today)