问题:
I am developing a comic app. I have three radio buttons which is english,french and Spanish respectively. And when the user clicks on any one of them the strings.xml from VALUES-ES,VALUES-FR and values-en should change the Strin G of the required references but and I-click on the radio buttons it does the references is still in Engish an D do not change to French or Spanish
Answer:
public class Androidlocalize extends Activity {Spinner Spinnerctrl; Button btn; Locale Mylocale; @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.main); Spinnerctrl = (Spinner) Findviewbyid (r.id.spinner1); Spinnerctrl.setonitemselectedlistener (New Onitemselectedlistener () {public void onitemselected (Adapterview<?>Parent, ViewView, IntPos, LongId) { If (Pos== 1) { Toast.Maketext(Parent.GetContext(), "You have selected Es", Toast.Length_short) .Show();SetLocale("Ta"); } Else If (Pos== 2) { Toast.Maketext(Parent.GetContext(), "You have selected Fr", Toast.Length_short) .Show();SetLocale("Hi"); } Else If (Pos== 3) { Toast.Maketext(Parent.GetContext(), "You have selected En", Toast.Length_short) show (); Setlocale ( } } public void Onnothingselected ( adapterview<?> arg0) {//TODO auto-generated method stub } }); public void SetLocale (String lang) {Mylocale = new Locale (lang); Resources res = getresources (); Displaymetrics DM = Res.getdisplaymetrics (); Configuration conf = res.getconfiguration (); Conf.locale = Mylocale; Res.updateconfiguration (conf, DM); Intent refresh = new Intent (this, androidlocalize.class); StartActivity (refresh); }}
turn from: Stack overflow
Set Android app Lanuage programatically