0

I'd like to create custom keyboard in my app. I've found that I should create new Input Method. But I don't know how to set this Method to my EditText and disable standard keyboard. I do not want user to have a possibility to change this keyboard. May I solve this with custom Input Method or should I create keyboard as custom view instead?

Kiryl Tkach
  • 3,118
  • 5
  • 20
  • 36
  • Just out of curiosity; what is going to be different about your custom keyboard? – Zimano Jun 26 '16 at 17:41
  • @Zimano: This will be keyboard from stndard android material design calculator, it will have decimal separator depending on locale and reveal effects on buttons – Kiryl Tkach Jun 26 '16 at 17:53

1 Answers1

3

But I don't know how to set this Method to my EditText and disable standard keyboard

You can't. The user chooses the input method, because the input method is system-wide.

May I solve this with custom Input Method or should I create keyboard as custom view instead?

Unless you are going to take the time to support all users — the visually impaired, those using a physical keyboard, etc. — you should not do this at all.

Assuming that you are going to handle all users, it would need to be a custom view if you are going to force the user to use it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So, if it will be a custom view, may I use it with a cursor in EditText? – Kiryl Tkach Jun 26 '16 at 17:30
  • 1
    @KirylTkach: Um, well, the cursor will be there by default. You would need to find where the cursor is and then splice in whatever character the user typed in at that cursor position. You will also need to be able to handle text selection/replacement, some sort of "backspace" option, and other things that users expect. Usually, the approach developers take is to not implement a keyboard, but rather simply validate the text to ensure that it meets whatever rules you have for what it should contain. – CommonsWare Jun 26 '16 at 17:33
  • Thanks for your help. I am going to use keyboard from android calculator. So if I'm going to disable standard keyboard, should I simply set inputMethod to none? – Kiryl Tkach Jun 26 '16 at 17:45
  • @KirylTkach: I forget the rules for disabling the normal keyboard. The calculator apps that I have used have not used an `EditText`. – CommonsWare Jun 26 '16 at 17:53