sometimes, a toast with a message may not be enough in this video, you will learn how to create a toast with a custom content first, create a custom view, either from the code or with an xml file for this example, i will use the second option create an xml file, which will represent the design that will be displayed in the toast
Android toast, now create a content when you finish, add an id to the root view or container of your design we will use it later when creating the toast it is time to load our custom content
we can use a layoutinflater to load our previously created xml since we are in an activity, we can call the getlayoutinflater method to get one once we have a layoutinflater, call the inflate method itself this method has two parameters: the name of the xml file created and taken as resource and a viewgroup that will be the root view or container that before we have put it an id for this task, create a toast from its constructor add it a duration and finally, put the custom view with the setview method now you can show the toast
there will be times you need to manipulate the elements within your layout for example, changing the image or textview's text as an example, i will take the latter so add it an id and then manipulate from the code to use a view or element of a layout call the findviewbyid method and send as parameter the name of the element as resource
then you can use the methods that this element has for this occasion, changing its text this is how to create a custom content for a toast
if you want to know how to position it in multiples places, whether custom or not, watch the following video