(values-ru)文字列値をローカライズしたい:textviewとapp_name。アプリはtextview( "Приветмир")のみをローカライズしますが、app_nameは同じ( "Localization")のままです。app_nameのローカリゼーションの問題は何ですか?
マニフェストのアプリラベル名とアクティビティラベル名は、適切な文字列値を参照しています。
マニフェスト:
<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>
文字列res/values-ru:
<resources>
<string name="hello_world">Привет мир</string>
<string name="app_name">Локализация</string>
</resources>
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);
}