phone 中的语言更改不会影响应用程序 - Android
Language change in the phone didn't affect the app - Android
<resources>
<string name="otpValidationMessage">Please enter the One Time Password\n and validate your phone number</string>
<string name="firstName">First Name</string>
<string name="lastName">Last Name</string>
<string name="mobileNumber">Mobile Number</string>
<string name="otpPassword">One Time Password</string>
<string name="code">Code</string>
<string name="resendOTp">Resend OTP</string>
我已经更改了 phone 语言,但我没有在我的应用程序中看到语言更改。我的所有文本都在字符串文件中,但应用程序中仍然没有任何变化。
在 onCreate 中执行此操作以将您的语言更改为阿拉伯语
myLocale = new Locale("ar");//"en" if you want english
Locale.setDefault(myLocale);
android.content.res.Configuration config = new android.content.res.Configuration();
config.locale = myLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
your_text_view.setText(R.string.Name);
并且在您创建的字符串中 res/values-ar/strings.xml
<string name="Name">Arabi</string>
并且在您创建的字符串中 res/values-en/strings.xml
<string name="Name">English</string>
如有任何疑问,请在下方评论
<resources>
<string name="otpValidationMessage">Please enter the One Time Password\n and validate your phone number</string>
<string name="firstName">First Name</string>
<string name="lastName">Last Name</string>
<string name="mobileNumber">Mobile Number</string>
<string name="otpPassword">One Time Password</string>
<string name="code">Code</string>
<string name="resendOTp">Resend OTP</string>
我已经更改了 phone 语言,但我没有在我的应用程序中看到语言更改。我的所有文本都在字符串文件中,但应用程序中仍然没有任何变化。
在 onCreate 中执行此操作以将您的语言更改为阿拉伯语
myLocale = new Locale("ar");//"en" if you want english
Locale.setDefault(myLocale);
android.content.res.Configuration config = new android.content.res.Configuration();
config.locale = myLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
your_text_view.setText(R.string.Name);
并且在您创建的字符串中 res/values-ar/strings.xml
<string name="Name">Arabi</string>
并且在您创建的字符串中 res/values-en/strings.xml
<string name="Name">English</string>
如有任何疑问,请在下方评论