

Public class MainActivity extends AppCompatActivity implements View.OnClickListener ĪrrayAdapter adapter = new ArrayAdapter (MainActivity.this Now Android Studio will complain by showing red line below View.OnClickListener telling you to implement the required method (OnClick), so just do it and the code will look like this. The reason you do it is because you have multiple Android Buttons which you need to make them clickable by using OnClickListener, which is easier and less code involve comparing with the other way of having to override OnClickListener for those 6 Buttons. Public class MainActivity extends AppCompatActivity implements View.OnClickListener

Spinner toastSize = findViewById(R.id.spToastSize) īutton normalToast = findViewById(R.id.btnNormalToast) īutton errorToast = findViewById(R.id.btnErrorToast) īutton warningToast = findViewById(R.id.btnWarningToast) īutton successToast = findViewById(R.id.btnSuccessToast) īutton infoToast = findViewById(R.id.btnInfoToast) īutton iconToast = findViewById(R.id.btnIconToast) ġ1- Next you need to implement View.OnClickListener by changing class declaration to the following. The function of these buttons are to show different types of custom Toast messages.ġ0- Now open up MainActivity.java, here you need to reference those views that you’ve created them earlier inside the xml file. This Spinner will be use to change the text size of Android Toast message.ĩ- Next you need to add those 6 Android Buttons. The TextView have a label that says (Choose Toast text size), below it there is a Spinner which have a margin bottom of (20dp). ( Large preview)ħ- Open up activity_main.xml file, in this file you need to add Android TextView, Spinner and 6 Buttons.Ĩ- First you need to add a TextView and a Spinner. ( Large preview)ĥ- Open up colors.xml file to change the colors of the main app.Ħ- Build and run the app to see the new colors.Ĭhanged colors of the app.

Implementation ':Toasty:1.3.0'ģ- Next you need to open up adle (Project) and add Maven because this library is available through it.Ĥ- Now sync your project by clicking on Sync Now.Īndroid studio sync project. ( Large preview)Ģ- Open up adle (module:app) and add the library in the dependencies. In this tutorial we will be using the following:ġ- Open up Android Studio and open any project that you have in your computer.Ĭreate new Android Studio project or open existing project. You will be using a 3rd party library called Toasty to help you make custom Android Toast.

This will make Android Toast more interactive and less boring 🙂īy the end of this tutorial, you will have an app that looks like this. Hello and welcome to another tutorial from Codingdemos, in this tutorial you will learn how to customize Android Toast message to something more colorful by including color and icon.
