Snackbarscan actually replace toasts and can be used instead. Of course, it can be noted that they can not replace toasts, but they can be considered as a new version of toasts. Snackbars are the tapes that are used to inform users when certain tasks or events are taking place.
To give a complete explanation of snackbars, we will give an example so that we can better explain it. Considerthe Gmailenvironment, where after sending a message to people, a message appears to the user that your message was sent and displays two buttons for the user that the user can delete or view again. This bar that is displayed to the user after the event is called Snackbar.Or in other cases, if the user deletes the sent message, the system will receive the message "Message is deleted".Another example to better understand Snackbar, we can say that a message is displayed for the user at the bottom that the system is not connected to the Internet, in this case, in addition to displaying the message to the user, a button to perform an action It shows that the user can take the necessary actions.In fact, the bar that is displayed in the system for information to the user and there is a button next to the action is called Snackbar.In the example of Gmail, the button to delete the message and in the example of not connecting to the Internet can be considered the action and the button of retry.Therefore, it can be said that one ofthe advantages and features of Snackbarover Toast is that in addition to displaying the appropriate message with the event for the user, it is also possible to put a button to perform the action.
1- InAndroidStudio, we create a new project and select the desired name for it. The name chosen in this tutorial is Snackbar.2- It is better to create the project with MinSDK 17 in Android Studio.3- Add the following codes inside the project:
dependencies {
4- The view in the Snackbar must be of the CoordinatorLayout type so that the snack bar capabilities can work properly.
implementation fileTree (dir: 'libs', include: ['* .jar'])
implementation 'com. android. support: appcompat-v7:27.0.2'
implementation 'com. android. support:design:27.0.2'
}
Read more on:
link:
Related link:
How to start learning Android development
Android article,How to work with cameras on Android devices in two ways
Android article,What are BroadcastReceiver in Android systems, why and how to use them?
Android article,What are floating buttons in Android systems and how can they be used?
Android article,How can we change the font in Android and how to solve different problems?
Android article,What are snackbars in Android systems and how can they be used?
Android article,What are the services in Android systems and when are they used?
the ,to ,that ,is ,in ,can ,the user ,to the ,can be ,in the ,that the
درباره این سایت