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. IMAP Email message body is "null"

Not sure if this is where bug reports go, but in lieu of a known
tracking mechanism here's my bug:

Synopsis: IMAP Email message body is "null"

Platform: T-Mobile G1

Issue: Using IMAP Email client, some messages contain a body
consisting of the word "null".  This is using the Sun Java System
Messaging Server.  The issue does not happen on all emails, just mail
from a particular sender; usually the sender is from an automated
email system, such as Clarify or Radiance.

Notes: Viewing the same emails from Thunderbird show the whole
message.

Thanks,
Brian

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

2. Starting Android Service at boot time

I am writing an application that has a service that runs a background
thread and polls web services.  The service creates notifications
using the NotificationManager.  The service needs to be running when
the phone is first booted and the user does not need to start an
activity to start the service.

What is the standard way to launch application service without user
intervention?  I could find any documentation that describes the
procedure.

Thank you,

Dave

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

3. Html5 Client-Side Storage support for android

4. Interested in LBS & AR? Android Developer Needed

5. Intercept incoming call

6. Html5 Client-Side Storage support for android

7. Affected by the MapsAPI-Tos only when (uses-library android:name="com.google.android.maps" /) ?