其实就是获取当前语言环境,然后返回相应的文字:
String language = LanguageManager.getLang();
if (language.equals(LanguageManager.ZH_CN.toLowerCase())) {
tabText = "爱情";
} else if (language.equals(LanguageManager.ZH_TW.toLowerCase())) {
tabText = ”愛情“;
}
其中获取语言环境方法:
public static Locale getLocale(Resources res) {
Configuration config = res.getConfiguration();
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
? config.getLocales().get(0)
: config.locale;
}
String language = locale.getLanguage();