Home  >  Article  >  php教程  >  Android 上实现微信微博上的应用语言切换

Android 上实现微信微博上的应用语言切换

WBOY
WBOYOriginal
2016-06-07 11:36:091183browse

Android 上实现微信微博上的应用语言切换,包含核心代码和ListPreference两部分
核心代码

Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
configuration.locale = getLocale(language);
resources.updateConfiguration(configuration, displayMetrics);


然后写一个ListPreference
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Intent intent = new Intent(**ivity, Main**ivity.class);
intent.putExtra("setLanguage", true);
**ivity.start**ivity(intent);
**ivity.finish();
}

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn