1 forms定义接口 2 3 using System; 4 5 namespace 6 { 7 public interface ISystemToast 8 { 9 void DisplayToast(string message); 10 } 11 } 12 13 14 平台实现 15 16 using System; 17 18 using Android.App; 19 using Android.OS; 20 using Android.Views; 21 using Android.Widget; 22 using Android.Content; 23 24 using Xamarin.Forms; 25 26 using.TDroid; 27 28 [assembly:Dependency(typeof(SystemToast))] 29 namespace.TDroid 30 { 31 public class SystemToast : Java.Lang.Object,ISystemToast 32 { 33 public void DisplayToast(string message) 34 { 35 Toast.MakeText (Android.App.Application.Context,message,ToastLength.Short).Show (); 36 } 37 } 38 }
时间: 2024-11-03 22:10:55