19

I am developing one android app in two different languages. When user click on "Change language" button it ask to choose language from two different languages option and change keyboard according to that language.

For example : User choose "Arabic" language then keyboard input language should automatically change from English to Arabic.

Please help me to resolve this issue.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Chetan Bhalara
  • 10,326
  • 6
  • 32
  • 51

2 Answers2

9

This isn't really that possible. You can change the users locale using a number of solutions present on stackoverflow already:

Here for example, or here for another.

However, this will only change the locale. The problem you will encounter is that the keyboard is itself an application. Therefore, you cannot change it directly from your app, nor can you guarantee that your user will have the "Arabic" charset or addon or whatever, for they keyboard app that they employ.

Your only real and reliable solution if you wish to accomplish what you need would be to create your own keyboard input. Otherwise, it will be in the user's hands to change their keyboard to Arabic.

Community
  • 1
  • 1
D Yao.
  • 391
  • 1
  • 6
  • 1
    Just adding that this is reinforced by custom keyboards: They always force you to change the input type yourself, though they do present you with the dialog that does this. (And keyboard languages count as an input type.) – Cat Sep 06 '12 at 15:47
  • @Eric, Can you elaborate more on this? – Chetan Bhalara Sep 07 '12 at 06:37
  • 2
    When you install a custom keyboard, most of them have a little setup procedure. First, you have to enable the keyboard in the settings, so the app will open that settings screen for you. Next, you have to switch input modes, so the app will open the input mode screen. If you want to try it, download TouchPal keyboard (it's free), and go through the setup procedure. You'll see what I mean. – Cat Sep 07 '12 at 16:27
6

(API 24+): If you are using a TextView/EditText, then you can call TextView#setImeHintLocales(LocaleList)

textView.setImeHintLocales(new LocaleList(new Locale("zh", "CN")));

Note: If you want new "hint" to take effect immediately you need to call InputMethodManager#restartInput(View).

DA_123
  • 337
  • 3
  • 10