导航:首页 > 操作系统 > android判断语言

android判断语言

发布时间:2024-05-12 20:35:23

Ⅰ 如何在android APP中设置系统语言

  1. 获取当前系统语言

  2. LocalecurLocale=getResources().getConfiguration().locale;

  3. //通过Locale的equals方法,判断出当前语言环境

  4. if(curLocale.equals(Locale.SIMPLIFIED_CHINESE)){

  5. //中文

  6. }elseif(Locale.ENGLISH){

  7. //英文

  8. }

  9. 2.设置APP语言Resourcesresources=getResources();//获得res资源对象
    • Configurationconfig=resources.getConfiguration();//获得设置对象

    • DisplayMetricsdm=resources.getDisplayMetrics();//获得屏幕参数:主要是分辨率,像素等。

    • config.locale=Locale.ENGLISH</span>;//设置APP语言设置为英文

    • resources.updateConfiguration(config,dm);

    • //设置完以后要刷新Activity才能及时生效

Ⅱ Android如何获取当前操作系统的语言

使用如下代码判断语言(这里判断下中文):

public static boolean isZh(Context context) {
Locale locale = context.getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith("zh"))
return true;
else
return false;
}

下面是判断国家:

中文:getResources().getConfiguration().locale.getCountry().equals("CN")

繁体中文: getResources().getConfiguration().locale.getCountry().equals("TW")

英文(英式):getResources().getConfiguration().locale.getCountry().equals("UK")

英文(美式):getResources().getConfiguration().locale.getCountry().equals("US")

如果不清楚当前国家的简写,可以直接

System.out(getResources().getConfiguration().locale.getCountry());打印出来即可。

Ⅲ android 怎样获取当前语言的设置

如果想获取手机的当前系统语言,可以通过Locale类获取,主要方法:Locale.getDefault().getLanguage(),返回的是es或者zh;通过Locale.getDefault().getCountry()获取当前国家或地区,返回为CN或US;如果当前手机设置为中文-中国,则使用此方法...

Ⅳ Android怎么获取当前操作系统的语言

Android--获取当前系统的语言环境其代码如下:

private boolean isZh() {
Locale locale = getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith("zh"))
return true;
else
return false;
}

其中languag为语言码:
zh:汉语
en:英语

Ⅳ android判断当前系统用的是什么语言

判断国家:
中文:getResources().getConfiguration().locale.getCountry().equals("CN")
繁体中文: getResources().getConfiguration().locale.getCountry().equals("TW")
英文(英式):getResources().getConfiguration().locale.getCountry().equals("UK")
英文(美式):getResources().getConfiguration().locale.getCountry().equals("US")

如果不清楚当前国家的简写,可以直接System.out(getResources().getConfiguration().locale.getCountry());打印出来即可

下面是判断是否是中文或者繁体中文(台湾):
[java] view plain
public boolean isLunarSetting() {
String language = getLanguageEnv();

if (language != null
&& (language.trim().equals("zh-CN") || language.trim().equals("zh-TW")))
return true;
else
return false;
}

[java] view plain
private String getLanguageEnv() {
Locale l = Locale.getDefault();
String language = l.getLanguage();
String country = l.getCountry().toLowerCase();
if ("zh".equals(language)) {
if ("cn".equals(country)) {
language = "zh-CN";
} else if ("tw".equals(country)) {
language = "zh-TW";
}
} else if ("pt".equals(language)) {
if ("br".equals(country)) {
language = "pt-BR";
} else if ("pt".equals(country)) {
language = "pt-PT";
}
}
return language;
}
String format = Settings.System.getString(context4Year.getContentResolver(), Settings.System.DATE_FORMAT);

希望我的回答可以帮到你!!

Ⅵ android 如何获取系统当前语言

Android--获取当前系统的语言环境其代码如下:

private boolean isZh() {
Locale locale = getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith("zh"))
return true;
else
return false;
}

其中languag为语言码:
zh:汉语
en:英语

阅读全文

与android判断语言相关的资料

热点内容
石家庄十万程序员 浏览:971
java继承类实例 浏览:286
疫情期间程序员的工资 浏览:27
最好的python编译器 浏览:187
安卓手机如何调分屏 浏览:729
安卓系统蓝牙耳机如何用 浏览:721
为什么微信不能给appstore充值 浏览:495
程序员的保护动物 浏览:274
程序员遇到问题去哪个网站 浏览:531
安卓手机空格键连续输入怎么取消 浏览:520
压缩空气管道流量计 浏览:564
ug编程高级教程 浏览:177
什么叫做服务器已满 浏览:37
暑假哪有教算法的 浏览:136
密码学的根基是加密 浏览:662
stata方差检验命令 浏览:337
解压后文件夹里的内容丢失 浏览:715
解压无敌视频 浏览:690
什么是服务器辨认不了 浏览:129
java如何调用类方法 浏览:483