2016-05-02 2 views
1

実行時に自分のアプリケーションの言語を変更したいと思います。 私はSOに関する多くの質問を検索し、指定されたコードを使用しましたが、このコードはゼリービーンの下でのみ動作します。ゼリー豆以上の場合はどうすればいいですか?ランタイム時のローカライゼーション上記のアンドロイドジェリービーン

Resources res = getContext().getResources(); 
       // Change locale settings in the app. 
       DisplayMetrics dm = res.getDisplayMetrics(); 
       android.content.res.Configuration conf = new Configuration(res.getConfiguration()); 
       conf.locale = nLocale; 
       res.updateConfiguration(conf, dm); 
       getActivity().recreate(); 

ありがとうございます。

答えて

2
Locale locale = new Locale(language); 
     Locale.setDefault(locale); 
     Resources resources = context.getResources(); 
     Configuration configuration = resources.getConfiguration(); 
     configuration.locale = locale; 
     resources.updateConfiguration(configuration, resources.getDisplayMetrics()); 
+0

パス文字列「こんにちは」のような言語と「en」とは – Krishna

+0

それは私がこのラインgetActivity()を使用したコードリフレッシュビュー –

+0

上機能していません)(再作成します。;しかし何も起こらない – Krishna

関連する問題