2017-08-17 61 views
0
<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> 

我已更改手機語言,但在應用程序中看不到語言更改。我在String文件中擁有所有文本,但仍然沒有更改。手機中的語言更改不會影響應用程序 - Android

+0

重新啓動活動 –

+0

檢查您的應用是否有固定的文字字體和大小 – Reena

+0

您是否可以通過屏幕查看字符串文件的結構? –

回答

1

在做的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 /值-AR/strings.xml中

<string name="Name">Arabi</string> 

和字符串創建爲資源/values-en/strings.xml

<string name="Name">English</string> 

如果您有任何疑問,意見下來

+0

但是創建一個文件所有語言都很難!有沒有一種方式,它動態地將字符串更改爲系統語言@GT – Racer

+0

是的課程其他手機如何獲得翻譯後的語言我們不得不提及它 – g7pro

+0

在此代碼中,texview具有arabi,如果ar被設置,則英語如果en是分別設置爲mylocale – g7pro