Android/App개발2011. 9. 3. 18:33


Locale을 생성 후 updateConfigurations로 변경한다.
 

Locale locale = new Locale("ko"); 

Locale.setDefault(locale);

Configuration config = new Configuration();

config.locale = locale;

getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());


변경 후 액티비티를 다시 시작하여야 변경된 로켈이 적용된다.
 
finish();

Intent myIntent = new Intent(MainActivity.this, MainActivity.class);

startActivity(myIntent);


이렇게 하면 해당 액티비티에만 적용된다.
액티비티를 시작할 때 이전에 선택한 로켈로 시작되게 하려면 onCreate에서 지정해야 한다.

onCreate(..) {
         Locale locale2 = new Locale("en"); 

    Locale.setDefault(locale2);

        Configuration config2 = new Configuration();

        config2.locale = locale2;

        getBaseContext().getResources().updateConfiguration(config2, getBaseContext().getResources().getDisplayMetrics());


        setContentView(R.layout.main);

}

setContentView(.)보다 이전에 설정해주어야 한다.

만일 이렇게만 하면 런타임에 로켈을 바꾸면 화면이 점점 더 작아지는 황당한 상황을 겪을 것이다.
Manifest에 다음을 추가해라.

<supports-screens

android:smallScreens="true"

android:normalScreens="true"

android:largeScreens="true"

android:anyDensity="true"

/>




 
Posted by 삼스