10

Assume that I have two text fields with the same layout e.g (Address), The first input requires the address to be in English and the keyboard should be shown in English by default, The second input requires the address to be in Arabic.

My question is: Can I show the keyboard with a specific language when needed, like Arabic Address.

Is there something like android:inputType"" for language?

George
  • 6,886
  • 3
  • 44
  • 56
  • @ShubhamSrivastava Change localization won't solve the Issue, also it's not a brute-force solution. –  Apr 17 '18 at 12:02
  • 1
    Hope this will help you https://stackoverflow.com/questions/36261166/change-keyboard-input-language-programmatically – Nandha Apr 17 '18 at 12:03
  • Please read the most upvoted [answer](https://www.stackoverflow.com/a/12303734) in the same question. It clearly states 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.If you wish to accomplish what you need would be to create your own keyboard input – Anonymous Apr 17 '18 at 12:05
  • @ShubhamSrivastava There should be a way to show a specific language, like showing specific characters using `inputType`. –  Apr 17 '18 at 12:07
  • I have retracted my flag , hope we find an answer to this ! – Anonymous Apr 17 '18 at 12:11
  • 3
    I don't think there is a way to restrict language for the EditText. You can restrict the list of allowed characters, and list all chars you allow in the field, but nothing you can do about the keyboard – Vladyslav Matviienko Apr 17 '18 at 12:14
  • I guess not, we don't have control to change localization of device programmatically, which further changes keyboard input language. – Dhaval Patel Apr 17 '18 at 12:36
  • `system apps` can set `custom keyboards` because they can use `android.permission.WRITE_SECURE_SETTINGS`, a normal app cannot. The `user` must change the `input type` themselves (user confirmation), though you can present them with a `dialog` that does this. – Jon Goodwin May 13 '18 at 09:58

1 Answers1

-1

You have a big work around about how to do this - which is create your own keyboard, and to do this you'll have to know the keyboards you're looking for. (which will be exact duplicate of the regular keyboard)

Here you can get some samples here & code samples.

How to make an Android custom keyboard?

Follow this link for making a custom keyboard And Finally

EditText editText = (EditText) findViewById(R.id.editText);
MyKeyboard keyboard = (MyKeyboard) findViewById(R.id.keyboard);

// prevent system keyboard from appearing when EditText is tapped
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);

// pass the InputConnection from the EditText to the keyboard
InputConnection ic = editText.onCreateInputConnection(new EditorInfo());
    keyboard.setInputConnection(ic);
Anisuzzaman Babla
  • 6,510
  • 7
  • 36
  • 53