Is there a way to programmatically remove certain keys from the standard software keyboard. By setting some of the input type flags I am so close to having the keyboard I need. From the calling application is there a way to modify the keyboard directly. I know how to make my own custom keyboard but it seems such a waste to remove one button from the standard one.
////// edit///////
I think I found a way around this if any one has tried this method please let me know if it worked for you.
I have going to grab the softKeyboard service and using the start hook the keyboard uses to grab its view object inflate my own and swap them.
From my research there is no way to implement your own custom keyboard from within a single application. If you want to have a custom keyboard you need to create one from scratch and can not use the IME
soft keyboard comes for edit text. you can modify the softkeyboard for that edit text.
For that you need to set inputType and imeOption property of that edit text.
Related
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?
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.
Is there any way to input special characters (which are not present in the default soft keyboard ,eg. theta) in an Android EditText?
Thanks..
Well as per your need, I would like to suggest to create a custom keyboard because the stock keyboard which comes with the device may not have the special characters you need.
You can refer the following tutorial to create a custom keyboard
http://www.fampennings.nl/maarten/android/09keyboard/index.htm
or you can see this search result which may serve your purpose,
https://github.com/search?q=android+custom+keyboard&ref=cmdform
And from below site you can get the list of Unicode characters which Android supports,
http://en.wikipedia.org/wiki/List_of_Unicode_characters
http://unicode-table.com/en/#0026
Note: Writing the whole code to create a custom keyboard is beyond the scope of this answer, so I mentioned the reference link.
What you are going to do is to create a custom keyboard. First thing you want is to hide the default keyboard when an EditText is focused:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Now, you must create a custom layout (RelativeLayout or Multiple LinearLayouts this is your desire), create and set text to the buttons that you want to show. Make this keyboard view setVisibility(View.INVISIBLE) or setVisibility(View.GONE), and whenever your EditText is focused, make it setVisibility(View.VISIBLE).
After keyboard is visible, programming the rest is up to you it is practically easy.
If you also need a guide, here is an example.
I don't want to replace the entire soft keyboard. I want to add a Next/Prev buttons when the soft keyboard is deployed when a field in my WebView in the fashion that looks like the display on mylogin.yahoo.com
http://imgur.com/a/zH0Ux
I have found this on github
https://github.com/chrisboyle/sgtpuzzles/blob/master/src/name/boyle/chris/sgtpuzzles/SmallKeyboard.java
which seems like a reasonable way to accomplish this functionality.
Is extending android.inputmethodservice.KeyboardView be a reasonable way to go?
Mark
Yes, extend it is the best way to go. Wrap what you want to add. Create another keyboard and set it to that keyboard.
I want to add some buttons on top of the soft keyboard (Enter and Cancel). Is there a nice way to do this or do I have to detect the keyboard being shown and add the buttons into my view?
I can't see the logic your trying to apply here.
if you add buttons above your keyboard then you lose some areas in your keyboard (for example you cant press on q w s a).
I think you should look into creating your own custom keyboard.
maybe this will help
android app specific soft keyboard
Jason
You won't be able to do this, and with good reason. If apps could modify an existing input method like this, they could trivially log all keystrokes on your device without you knowing. If you've ever installed a custom input method, you'll see a big warning that using it means trusting it not to log your keystrokes, and the functionality you're after would totally circumvent that protection.
Is there a way to create an app specific soft keyboard on Android? After reading about InputMethodService docs and checking out alternative keyboard apps out there, I figure the alternate keyboard can only be configured for system wide usage (through Settings -> Locale and Text).
If the answer to above question is no, then is there at least a way to load a custom dictionary and override the default dictionary of the system keyboard (only when my app is in use)? That will help in giving very relevant suggestions to the user when he has only tapped couple of keys.
If you just want a View that looks and acts like a soft keyboard, I did that in my SmallKeyboard class. You just need to extend android.inputmethodservice.KeyboardView and decide on layout. See the onKey and onText methods at the end of that file for the action taken when keys are pressed.
Instead of my keyboard model inner class, you could load it from XML if your key set is fairly constant.
The Android Nethack application has a complete and clear source code example of how to create a custom keyboard for an application, how to display it on screen and how to define multiple keyboard layouts. It contains pretty much everything you need to know.
It is by far the best example I have seen.
http://code.google.com/p/nethack-android/