Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-07 11:36:09
Original
1188 people have browsed it

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元

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template