android - How to change keyboard layout in onSwipe method? -
i know how change keyboard layout in onswipe
method.
have qwerty.xml
letters, need numbers , symbols.
these 2 groups of characters in numeric.xml
.
numeric.xml
show , qwerty.xml
hidden when swipe left or right.
if need part of code please ask.
you need change layout on keyboard object in inputmanagerservice. need invalidate keys keyboard redrawn. so:
public class mykeyboard extends inputmethodservice implements keyboardview.onkeyboardactionlistener { private keyboardview mykeyboardview; private keyboard mykeyboard; public view oncreateinputview() { viewofkeyboard = (keyboardview)getlayoutinflater().inflate(r.layout.keyboard1, null); thekeyboardlayout = new keyboard(this, r.xml.keyboardlayout); viewofkeyboard.setkeyboard(thekeyboardlayout); viewofkeyboard.setonkeyboardactionlistener(this); return mykeyboardview; } public void swiperight() { if(isqwerty) { mykeyboard = new keyboard(this, r.xml.numeric); //creates new keyboard object. mykeyboardview.setkeyboard(mykeyboard); //assigns new keyboard object keyboard view mykeyboardview.invalidateallkeys(); //makes android redraw keyboard view, new layout. isqwerty = false; } else { mykeyboard = new keyboard(this, r.xml.qwerty); mykeyboardview.setkeyboard(mykeyboard); mykeyboardview.invalidateallkeys(); isqwerty = true; } //.........the rest of mykeyboard's methods }
Comments
Post a Comment