And*_*rew 2 string android localization
我想本地化(values-ru)字符串值:textview和app_name.应用程序仅本地化textview("Приветмир"),但app_name仍然相同("本地化").app_name本地化有什么问题?
Manifest中的应用程序标签名称和活动标签名称是指相应的字符串值.
表现:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.local.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
字符串res/values-ru:
<resources>
<string name="hello_world">?????? ???</string>
<string name="app_name">???????????</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
Java的:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languageToLoad = "ru";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
setContentView(R.layout.activity_main);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2029 次 |
| 最近记录: |