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 | AdMob Banner Ads for Android Studio
- Android | AdMob Interstitial Ads for Android Studio
- Android | How to Create/Start a New Project in Android Studio?
- How to install Android Applications in Mobile Phone without USB Cables using Android Studio
- How to implement Swipe Down to Refresh in Android using Android Studio
- How to Add OpenCV library into Android Application using Android Studio?
- Guide to Install and Set up Android Studio
- How to build a simple Calculator app using Android Studio?
- 10 Important Android Studio Shortcuts You Need the Most
- How to scale different Views to all screen sizes in Android Studio?
- How to create a Stopwatch App using Android Studio
- How to Upload Project on GitHub from Android Studio?
- How to build a simple music player app using Android Studio
- Logcat window in Android Studio
- Guessing the Number Game using Android Studio
- How to populate RecyclerView with Firebase data using FirebaseUI in Android Studio
- How to Generate Signed Apk in Android Studio?
- Android Studio Setup for Flutter Development
- How to Create Your Own Shortcut in Android Studio?
- How to Convert SVG, PSD Images to Vector Drawable File in Android Studio?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.