Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Android.Content;
- using Android.Content.Res;
- using Android.Util;
- using Java.Util;
- namespace ReadyApps.Xamarin.Framework.Droid
- {
- public class LanguageUtil
- {
- public static void ChangeLanguageType(Context context, Locale localelanguage)
- {
- var resources = context.Resources;
- DisplayMetrics dm = resources.DisplayMetrics;
- Configuration config = resources.Configuration;
- if (VersionUtils.isAfter24())
- {
- config.SetLocale(localelanguage);
- }
- else
- {
- config.Locale = localelanguage;
- resources.UpdateConfiguration(config, dm);
- }
- }
- public static Locale getLanguageType(Context context)
- {
- var resources = context.Resources;
- Configuration config = resources.Configuration;
- if (VersionUtils.isAfter24())
- {
- return config.Locales.Get(0);
- }
- else
- {
- return config.Locale;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement