0
Google은 사용자가 선택할 수있는 Android 앱에서 총 6 개 언어를 사용하고 있습니다. 우리는 프로그래밍 방식으로 로케일을 설정하고 있습니다. 언어는 영어, 힌디어, 타밀어, 텔레구, 칸나다어, 말라 얄 람어, 마라 티어입니다.앱 상태 Android 앱 내 언어를 변경할 때 변경됨
아래 코드를 사용하여 앱의 언어를 변경합니다.
locale = new Locale(lang);
Locale.setDefault(locale);
Configuration conf = new Configuration(config);
conf.locale = locale;
getApplicationContext().getResources().updateConfiguration(conf,getBaseContext().getResources().getDisplayMetrics());
우리는 힌디어와 영어 응용 프로그램의 언어를 변경
공유 환경 설정에서 데이터를 얻을 수 있지만, 다른 언어, 같은 쿼리에 대해 null를 돌려줍니다. 도와주세요업데이트 1 : 다음은 문제가 발생하는 이유가 된 SharedPreferences R.string.shared_prefs_key
에서 데이터를 얻기 위해 문자열 값을 사용하고 있기 때문에 공유 선호
SharedPreferences sharedPrefs = context.getSharedPreferences(context.getString(R.string.shared_prefs_key), Context.MODE_PRIVATE);
String value = sharedPrefs.getString(key, null);
'는 같은 query.' 쇼 작업 null을 반환 : 상수 값을 아래와 같이 그
변경 –