In this lesson, you will learn how to very quickly show simple messages to the user, or to take confirmation or text input using the Alert class.
By default, it gives you a single button named "OK". But you can also use the other overloads of the Alert class to define your own button(s).
If your message is long, then you can use another override to show a message in the title. This allows you to use the title to display the main point to the user and then provide more details if the users interested in learning more.
By default, Alert.Show() will display the single OK button. But you can customize and change the button text and allow users to select one. Each option will be a key value pair where the key is the text of the button and the value can be any type.
KeyValuePair.of("Option 1", 1),
KeyValuePair.of("Option 2", 2),
KeyValuePair.of("Option 3", 3)
The Alert class has another method named Confirm() which is a simple shortcut to creating and alert by Confirm and Cancel buttons, representing True and False.
You can use Alert.Prompt() function to get value from users. If user do not input any data, it returns Null value.
// Use input ...
Toast is a little text popup to show some notification message to the user in a non-intrusive way. It automatically disappears after a few seconds.
Unlike a message box, it doesn't block the user experience and force the user to tap OK.
By default, it shows an OK button next to your message, but you can optionally remove that.
If you want to show the message without OK button, you should set showButton property on false .