Posts

Showing posts with the label Xamarin.android

Xamarin Forms toaster notification for android and iOS

A simple solution is by using the Dependency Service you can easily get the Toast notification in both Android and iOS.   Create an interface in your Xamarin forms package. public interface IMessage { void LongAlert ( string message ) ; void ShortAlert ( string message ) ; }   Android Project   [ assembly: Xamarin.Forms.Dependency(typeof(MessageAndroid)) ] namespace Your.Namespace { public class MessageAndroid : IMessage { public void LongAlert ( string message ) { Toast.MakeText(Application.Context, message, ToastLength.Long).Show(); } public void ShortAlert ( string message ) { Toast.MakeText(Application.Context, message, ToastLength.Short).Show(); } } }    iOS Project   [ assembly: Xamarin.Forms.Dependency(typeof(MessageIOS)) ] namespace Your.Namespace { public class MessageIOS : IMessage { const double LONG_DELAY = 3....

Remove icon from action bar for xamarin forms android project

Put the below code in xamarin.android (xamarin.droid) project. [assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationRenderer))] namespace Example {     public class RootNavigationRenderer : NavigationRenderer     {         protected override void OnElementChanged(ElementChangedEventArgs e)         {             base.OnElementChanged(e);             RemoveAppIconFromActionBar();         }         void RemoveAppIconFromActionBar()         {             var actionBar = ((Activity)Context).ActionBar;             actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid()));         }     } }