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
- Guide to Install and Set up 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?
- Android | Starting with first app/android project
- Android | Running your first Android app
- Android | 8.0 Oreo
- How to use WebView in Android
- Android | RecyclerView
- How to use CheckBox in Android
- Android | App to Add Two Numbers
- Adding Firebase to Android App
- Volley Library in Android
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.