我想本地化(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>
字符串RES /值儒:
<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);
}
感谢您的快速回复 – Andrew
这是一个可靠的答案。但我相信,如果你告诉如何克服这种情况,它将会帮助社区更多。 – Killer
我们是否需要为每个活动使用setTitle ... – Killer