Android custom keyboard - How to detect requested keyboard type -
following this tutorial have created working android os keyboard. standard qwerty alpha/numeric.
i have second keyboard mark-up numeric keyboard.
what can't seem detect type of keyboard being specified text input box. edittext specifies type edittext.setinputtype(inputtype.type_class_text);
how ime service detect can present correct keyboard?
public class mykeybdime extends inputmethodservice implements keyboardview.onkeyboardactionlistener { private keyboardview kv; private keyboard keyboard; private keyboard numboard; private boolean caps = false; @override public view oncreateinputview() { kv = (mkeyboardview)getlayoutinflater().inflate(r.layout.keyboard, null); keyboard = new keyboard(this, r.xml.qwertyfull); numboard = new keyboard(this, r.xml.num); // inputmethodmanager imm = (inputmethodmanager) getsystemservice(context.input_method_service); //how can detect being asked for? // imm.togglesoftinput(inputmethodmanager.show_forced,0); // or on wrong path part? kv.setkeyboard(keyboard);//... or numboard when entry requests numeric keyboard kv.setonkeyboardactionlistener(this); return kv; }
you can override onstartinput
in custom keyboard class. here relevant code taken sample android keyboard:
@override public void onstartinput(editorinfo attribute, boolean restarting) { // ... switch (attribute.inputtype & inputtype.type_mask_class) { case inputtype.type_class_number: // ... break; case inputtype.type_class_datetime: // ... break; case inputtype.type_class_phone: // ... break; case inputtype.type_class_text: // ... break; default: // ... } // ... }
Comments
Post a Comment