Different Types of Android Toast Messages




A Toast provides simple feedback about an operation in a small popup,normal shown the at bottom part of a Android Application. There are basic and custom toasts used by developers to reach their users more interatively, basic toasts can only provide a normal amount of results to the user but using a custom toast will expand the result and enhance advantages.

This time we're creating a basic toast with different types of themes. Take a look below

you can watch the complete tutorial with exact vocals and understand here

Otherwise you can design from below codes!


Method 1



 Toast.makeText(getApplicationContext(),"No more items.", Toast.LENGTH_LONG).show();  


Result

[result from a Samsung Device running Android 4.2]



Method 2


 Toast.makeText(MainActivity.this,"No more items.", Toast.LENGTH_LONG).show();  



Result

[result from a Samsung Device running Android 4.2]


Conclusion
In both case you can see different type of toast theme, while using getApplicationContext() in the first method will use a basic android theme & in the second case we added MainActivity.this which is our activity name and this time   our application use android device's theme for toasts and application appearance. In this case running this app in Samsung device let it use it's TouchWiz Launcher to design App UI.



Hope you find it useful,
Thanks for your time!






1 comment:

Powered by Blogger.