A toast provides a simple popup message that is displayed on the current activity UI screen (e.g. Main Activity).
We can also create toast with single line by passing variables directly to makeText() function. This method takes three parameters context, popup text message, the toast duration. After creating Toast object you can display the toast by using show() method.
Creating a Custom Toast :
If you are not satisfied with simple Toast view in Android, then you can go ahead to make a custom Toast. Actually, custom Toast is a modified simple Toast that makes your UI more attractive. So that when you create a custom Toast then two things are required, one is XML (custom_toast.xml) required for layout view of custom Toast and another is activity class (custom_activity.class) file where you can write Java code. Java class file passes the root View object to the setView(View) method.
This is a XML layout for example purposes, so if you want your own design then you can create your own XML.
- Android | How to Create/Start a New Project in Android Studio?
- Android | AdMob Interstitial Ads for Android Studio
- Android | AdMob Banner Ads for Android Studio
- Guide to Install and Set up Android Studio
- 10 Important Android Studio Shortcuts You Need the Most
- How to create a Stopwatch App using Android Studio
- Guessing the Number Game using Android Studio
- How to Upload Project on GitHub from Android Studio?
- How to build a simple Calculator app using Android Studio?
- How to scale different Views to all screen sizes in Android Studio?
- How to build a simple music player app using Android Studio
- Android | Android Application File Structure
- Android | How to Request permissions in Android Application?
- Android | How to add Radio Buttons in an Android Application?
- Speech To Text using IBM Watson Studio
- Link your GitHub Account with R Studio
- Difference between Android 1.0 and Android 4.1
- Difference between Android 1.0 and Android 1.1
- Difference between Android 1.1 and Android 2.3.4
- Difference between Android 1.1 and Android 3.2.6
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.