Programming/Android

[Android] 코드상에서 언어 설정 변경하기

Kanais 2016. 5. 24. 10:28


 원글 작성날짜 : 2012-07-05

 수정 날짜 : 2016-06-28



출처 : 안드로이드펍 - 원조안드로이드

        머라카노 - 안드로이드 현재 설정된 언어 가져오기


현재 설정된 언어 가져오기


Locale locale = getResources().getConfiguration().locale;

String displayCountry =  locale.getDisplayCountry();

String country =  locale.getCountry();

String language =  locale.getLanguage(); 


 Locale en = Locale.US;

Configuration config = new Configuration();
config.locale = en;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());


위에 처럼 하시면 기존의 각 언어별 values 폴더의 strings.xml을 사용하시는 효과는 볼 수 있습니다.