Toast in android using xamarin forms


When we want to let user know that something happening we can use Toast.

Let’s see how to create Toast in in Android in Xamarin Forms

Create xamrin foms application with Android project


  • In .net standard project add a Interface
public interface IToastMessageService
void ShowToastMessage(string message);

  • In Android project add ToastMessageService and implement the IToastMessageService
[assembly: Xamarin.Forms.Dependency(typeof(ToastMessageService))]
namespace ToastTestXamarin.Droid
public class ToastMessageService : IToastMessageService
public void ShowToastMessage(string message)
Toast.MakeText(Android.App.Application.Context, message, ToastLength.Long).Show();

  • In MainPage.xaml add a button
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
<Button x:Name="BtnToastMessage" Text="Show Toast" Clicked="ShowToast"></Button>

view raw
hosted with ❤ by GitHub

  • And in the code behind implement the event handler
private void ShowToast(Object sender, EventArgs args)
DependencyService.Get<IToastMessageService>().ShowToastMessage("Test Toast Message");

view raw
hosted with ❤ by GitHub

Finally run the project 🙂



Get the sample project on Github

One thought on “Toast in android using xamarin forms

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s