Change the language of the Android application

I am developing one Android application,

In this application I need to use 5 languages,

The application allows the user to select a different language. according to user select language

for this, what should I do?

give me some suggestion for this .....

+3
source share
4 answers

You can provide localization. Please refer website

0
source

This is easy to do .. for example, using a spinner to select a language. See the following code ...

public void onCreate(Bundle savedInstanceState) {

    mTts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
}
            public void onInit(int status) {
                if (status != TextToSpeech.ERROR) {
                    ttsIsInit = true;
                }
            }
        });


read.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mTts != null && ttsIsInit) {
                    mTts.speak(exitTextFound, TextToSpeech.QUEUE_FLUSH, null);
                }
            }
        });


public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3) {

        language = language_array[spinner.getSelectedItemPosition()];

        if (language.equals("English US")) {
            mTts.setLanguage(Locale.US);
        } else if (language.equals("Francais")) {
            mTts.setLanguage(Locale.FRANCE);
        } else if (language.equals("Espanol")) {
            mTts.setLanguage(new Locale("es"));
        }
    }
+1
source

, , (, ) .

strings.xml .

, , , thread. , - .

0

: , .

:

  • XML , .
  • XML _languagecode, _fr ( !)
  • XML
  • XML

:

 String languageInitials = MyAppconfig.currentLanguageInitials();
        if (languageInitials.equals("NL")) {
            view = inflater.inflate(R.layout.mylayout_nl, container, false);
        } else {
            view = inflater.inflate(R.layout.fragment_mylayout_fr, container, false);
        }

XML- .

0

All Articles