我正在嘗試使用 Plugin.Toast Nuget-Package 在 Xamarin.Forms 中制作敬酒訊息。
呼叫 Toast 的類:
using Plugin.Toast;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Essentials;
namespace toast.service
{
public class toast
{
public void toastWarning(string msg)
{
CrossToastPopUp.Current.ShowToastWarning(msg, Plugin.Toast.Abstractions.ToastLength.Short);
}
}
}
呼叫吐司代碼:
service.toast toast = new service.toast();
toast.toastWarning("test");
但我總是收到此錯誤:System.NullReferenceException:'物件參考未設定為物件的實體。'
uj5u.com熱心網友回復:
無需使用插件。Xamarin提供Android.Widget.Toast庫以顯示訊息。
Toast.MakeText(this, "Received intent!", ToastLength.Short).Show();

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/480359.html
