Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Application language change

Tags:

android

I am developing one android application,

In that application i need to use 5 languages,

application lets user to choice different language. according to user select the language

for that what i have to do?

give me any suggestion for this.....

like image 372
dilipkaklotar Avatar asked Dec 13 '25 14:12

dilipkaklotar


1 Answers

This is easy to do.. for example using 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"));
        }
    }
like image 164
Hassan Avatar answered Dec 16 '25 06:12

Hassan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!