我试图允许用户在键盘之间切换,例如从Qwerty切换到笑脸键盘。我无法理解用户如何通过使用移位或通过全球按钮在iPhone上从Qwerty切换到表情符号的概念。我对如何编码实际的“开关”感到困惑。我在软键盘SDK示例中找到了以下代码,我想知道这是否是切换的方式。
private void handleShift() {
if (mInputView == null) {
return;
}
Keyboard currentKeyboard = mInputView.getKeyboard();
if (mQwertyKeyboard == currentKeyboard) {
// Alphabet keyboard
checkToggleCapsLock();
mInputView.setShifted(mCapsLock || !mInputView.isShifted());
} else if (currentKeyboard == mSymbolsKeyboard) {
mSymbolsKeyboard.setShifted(true);
mInputView.setKeyboard(mSymbolsShiftedKeyboard);
mSymbolsShiftedKeyboard.setShifted(true);
} else if (currentKeyboard == mSymbolsShiftedKeyboard) {
mSymbolsShiftedKeyboard.setShifted(false);
mInputView.setKeyboard(mSymbolsKeyboard);
mSymbolsKeyboard.setShifted(false);
}
}
我再次试图初始化一个开关,允许用户按下shift键并切换到表情符号,一旦选择切换回qwerty发送...
答案 0 :(得分:0)
只要按下shift键,样本软键盘就会被编码为从符号键盘变为符号移位键盘。要将表情符号键盘布局添加到旋转,请将发布的代码更改为以下内容:
private void handleShift() {
if (mInputView == null) {
return;
}
Keyboard currentKeyboard = mInputView.getKeyboard();
if (mQwertyKeyboard == currentKeyboard) {
// Alphabet keyboard
checkToggleCapsLock();
mInputView.setShifted(mCapsLock || !mInputView.isShifted());
} else if (currentKeyboard == mSymbolsKeyboard) {
mSymbolsKeyboard.setShifted(true);
mInputView.setKeyboard(mSymbolsShiftedKeyboard);
mSymbolsShiftedKeyboard.setShifted(true);
} else if (currentKeyboard == mSymbolsShiftedKeyboard) {
mSymbolsShiftedKeyboard.setShifted(false);
mInputView.setKeyboard(mEmoticonKeyboard);
mSymbolsKeyboard.setShifted(false);
} else if (currentKeyboard == mEmoticonKeyboard) {
mInputView.setKeyboard(mSymbolsKeyboard);
}
}