eva
eva

Reputation: 31

How to change language of keyboard in spanish programatically in android

I am working in app that have an option to select language. there are two radio button . one for Spanish and other is English. when user select Spanish ,I should change the keyboard in spanish. How can i do that? Please reply me.

Upvotes: 3

Views: 2234

Answers (2)

dendini
dendini

Reputation: 3952

Yes in Android you can do almost everything as long as the user accepts upon installation to give control of system settings to your application.

Basically you get the current settings and edit the value contained for language, as below:

    Resources res = context.getResources();
    // Change locale settings in the app.
    DisplayMetrics dm = res.getDisplayMetrics();
    android.content.res.Configuration conf = res.getConfiguration();
    conf.locale = new Locale(language_code.toLowerCase());
    res.updateConfiguration(conf, dm);

Hope it helps

Upvotes: 0

D.Bish
D.Bish

Reputation: 208

Someone may correct me but I'm fairly certain there is no option to do that at runtime. The keyboard itself is an application and therefore to change the input language the user has to do that themselves in the settings of whatever keyboard they are using. You can not change it from your app.

Upvotes: 4

Related Questions