Android 开发了软键盘-如何切换视图/服务?

Android 开发了软键盘-如何切换视图/服务?,android,image,service,keyboard,emoticons,Android,Image,Service,Keyboard,Emoticons,我目前使用InputMethodService开发了一个软键盘 它目前创建了一个功能强大的QWERTY键盘: public class KeyboardIME extends InputMethodService implements KeyboardView.OnKeyboardActionListener { private KeyboardView kbv; private Keyboard keyboard; @Override public void onKey(int

我目前使用InputMethodService开发了一个软键盘

它目前创建了一个功能强大的QWERTY键盘:

public class KeyboardIME extends InputMethodService
    implements KeyboardView.OnKeyboardActionListener {

private KeyboardView kbv;
private Keyboard keyboard;


@Override
public void onKey(int primaryCode, int[] keyCodes) {
    InputConnection ic = getCurrentInputConnection();
    playClick(primaryCode);
    switch(primaryCode)
    {
        case Keyboard.KEYCODE_DELETE :
            ic.deleteSurroundingText(1, 0);
            break;
        case Keyboard.KEYCODE_SHIFT:
            caps = !caps;
            keyboard.setShifted(caps);
            kv.invalidateAllKeys();
            break;
        case Keyboard.KEYCODE_DONE:
            ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN,   
             KeyEvent.KEYCODE_ENTER));
            break;
        default:
            String codeText = (String) String.valueOf(primaryCode);
            char code = (char)primaryCode;

            if(Character.isLetter(code) )
            {
                if(caps)
                {
                    code = Character.toUpperCase(code);
                }
            }
            else if (Integer.valueOf(codeText)==3890)
            {
                System.out.println("Testing to see if I can make a switch here..");
                break;
            }
            else {
                ic.commitText(String.valueOf(code), 1);
                break;
            }
      }





      @Override
     public View onCreateInputView() {


      kbv = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard, null);
      keyboard = new Keyboard(this, R.xml.qwerty);
      kbv.setKeyboard(keyboard);
      kbv.setOnKeyboardActionListener(this);

      return kbv;

}
我在键盘上有一个按钮,当用户按下它时,我希望它切换到“不同的键盘”——即切换到不同的视图。我希望另一个键盘上有表情符号。但我不知道该如何切换


有人能给我提供一些技巧、解决方案或可能的文档,我可以仔细阅读以了解这一点吗?

您可以在onCreateInputView方法上放大布局

@凌驾 公共视图onCreateInputView(){

然后你可以创建更多的键盘和设置可视性

键盘

kv=(键盘视图)GetLayoutFlater()。充气(R.layout.keyboard, 无效)

键盘qwerty

kv2=(KeyboardView)GetLayoutFlater().充气(R.layout.keyboard,null)

    View view = getLayoutInflater().inflate(R.layout.activity_main, null);
    yourLayout = (LinearLayout) view.findViewById(R.id.layout);
    return view;


}
            keyboard = new Keyboard(mContext, R.layout.nums);
            kv.setKeyboard(keyboard);
            kv.setOnKeyboardActionListener(onKeyboardActionListener);
            keyboard2 = new Keyboard(mContext, R.layout.qwerty);
            kv2.setKeyboard(keyboard);
            kv2.setOnKeyboardActionListener(onKeyboardActionListener);