导航:首页 > 操作系统 > 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判断语言相关的资料

热点内容
乐一php程序员待遇 浏览:162
ZDM命令无法识别 浏览:918
解压小手工A4纸 浏览:975
钢筋加密区是几倍 浏览:664
编译程序代码软件 浏览:800
怎么恢复加密的东西 浏览:981
程序员卖茶 浏览:697
后端程序员英文 浏览:360
滴滴程序员平均月薪 浏览:591
如何使用ftp命令 浏览:787
小书亭下载的文件在哪手机文件夹 浏览:176
交叉编译器编译单个c文件 浏览:513
代理服务器地址列表吧 浏览:930
java列出所有文件 浏览:868
压缩包看图软件 浏览:191
sqlite在android中的应用 浏览:661
一本通pdf 浏览:916
2021免费的编程软件 浏览:126
项目编译后浏览器不对应刷新 浏览:567
三星升级android60 浏览:297