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. Is this possible with Android

I am thinking about this scenario

1.In  a mobile with Android will be running my script.

2. Someone will dial the number( say number A)  of that mobile where
the script is running.

3.The script will answer and ask the caller( the caller has say number
B) to dial the number where  he wants to be connected to( say number
C)

4.The caller ( with his number   B )will  enter the number C

5.The script will dial that number C and makes  the connection
between  number B and C so that they can talk together.

Is this possible to do that with Android?

Thanks
L.

-- 

2. is there anyway to force locale system numeric to English ?

Hi

This Problem Appeared in my SmartPhone and SDK Emulator 2.3

after changing the language to arabic

i can't add new contact it force close
but when i change language back to english the problem disappeared

i think this problem because the system read the number in arabic
locale

look at this

Caused by: android.database.sqlite.SQLiteException: no such column:
: , while compiling: SELECT
raw_contacts._id,display_name,display_name_source,account_type,account_name,sourceid,custom_ringtone,send_to_voicemail,last_time_contacted,times_contacted,starred,is_restricted,name_verified,data._id,data.mimetype_id,is_super_primary
FROM raw_contacts LEFT OUTER JOIN data ON
(data.raw_contact_id=raw_contacts._id AND ((mimetype_id= AND data15
NOT NULL) OR (mimetype_id= AND data1 NOT NULL))) WHERE
raw_contacts._id=?

inside this query there is arabic number and it should not be arabic

i think Force Localize Contacts App to english After decompile it with
apktool and baksmali will fix this problem

http://www.tutorialforandroid.com/2009/01/force-localize-application-on-android.html
this is tutorial but i don't know how to apply it without problem

-- 

3. how can i make non-sqlite cursor?

4. GridView onItemClickListener

5. How to convert a image into Base64 string?

6. Emulator GPS Elevation Problem/Bug?

7. problem while executing sql query