Switch the language of all app dynamically!

by Stephen Le » Fri, 13 Mar 2009 01:42:40 GMT


Sponsored Links
 Hi all:

I must change en_US Locale into zh_CH dynamically(Like user choose
it). I writed a demo where the code is following:

public void onClick(View v){
     Resources resource=super.getResources();
     Configuration cf=resource.getConfiguration();
     DisplayMetrics dm =resource.getDisplayMetrics();
     cf.locale=Locale.CHINA;
     resource.updateConfiguration(cf, dm);

((TextView)super.findViewById(R.id.usernamelabel)).setText
((super.getResources()).getString(R.string.username));
((TextView)super.findViewById(R.id.passwordlabel)).setText
((super.getResources()).getString(R.string.password));
((Button)super.findViewById(R.id.loginbutton)).setText
((super.getResources()).getString(R.string.loginbutton));
((Button)super.findViewById(R.id.cancelbutton)).setText
((super.getResources()).getString(R.string.cancel));
((Button)super.findViewById(R.id.i8nbutton)).setText
((super.getResources()).getString(R.string.i8nbtn));

}//the end of onClick block

The code works fine.But I think this is very heavy to android
developer so I have to change every activity . Is there anyone know
the quicky way to change language setting?Please tell me the detail
steps if you know. Thanks!


TIP: My enviroment: android-sdk-windows-1.0_r2+JDK 6


--~--~---------~--~----~------------~-------~--~----~



Switch the language of all app dynamically!

by MrSnowflake » Fri, 13 Mar 2009 03:54:00 GMT


 Try saving the locale some way, make your own implementation of
Application and change the locale in Application. Then when the users
wants a new locale, restart the activity/task.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Penampakan

tadi saat boss oon lg presentasi, ada rame2 dibelakang... ternyata ada yg sudah 
pakai MileStone!

ck ck ck...

Salam,

Lucky Sebastian
@android
--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

2. RA-dream-v1.5.0 ... Masih Hangat lho .....

Just info, Recovery *RA-dream-v1.5.0  baru aja keluar di xda developer. ini
link nya : http://forum.xda-developers.com/showthread.php?t=566669


Selamat mencicipi ....


Salam
*

--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. Asik, kita bakal dapet kecanggihan baru:-)

4. Motorola Milestone - USB Driver won't be installed

5. Using external source inside my program (Eliminating Swing components)

6. A2DP problem in Eclair

7. Just a though about Android Market