android更改键盘布局,如何通过按Shift键更改android的键盘布局

android更改键盘布局,如何通过按Shift键更改android的键盘布局我目前正在自己​​的实现InputMethodEditor(IME)或可以在Android中调用Softkeyboard我已阅读creatinganinputmethod我已经下载theSoftKeyboardsamplecodeprovidedaspartoftheSDK。我有以下代码sampleSoftkeyboard:如何通过按Shift键更改android的…

大家好,欢迎来到IT知识分享网。

我目前正在自己​​的实现Input Method Editor (IME)或可以在Android中调用Softkeyboard我已阅读creating an input method我已经下载the SoftKeyboard sample code provided as part of the SDK。我有以下代码sample Softkeyboard:如何通过按Shift键更改android的键盘布局

private void handleCharacter(int primaryCode, int[] keyCodes) {

if (isInputViewShown()) {

if (mInputView.isShifted()) {

primaryCode = Character.toUpperCase(primaryCode);

}

}

if (isAlphabet(primaryCode) && mPredictionOn) {

/**

* Swapping here with my desired unicode character

* */

if (primaryCode >= 97 && primaryCode <= 122) {

mComposing.append(Swap.swapLetters(primaryCode));

}else{

mComposing.append((char) primaryCode);

}

getCurrentInputConnection().setComposingText(mComposing, 1);

updateShiftKeyState(getCurrentInputEditorInfo());

updateCandidates();

} else {

getCurrentInputConnection().commitText(

String.valueOf((char) primaryCode), 1);

}

}

上面给出的代码工作正常,但是当我点击的关键是:

android:keyWidth=”15%p” android:isModifier=”true”

android:isSticky=”true” android:keyEdgeFlags=”left”/>

这就好比Shift键,将其转换键为大写我不“知道如何表达我的下一个键时,该按键被按下/压,以下是例外的Logcat:

765e9a7cf5b3db670332883f7580dfd6.png

我已经查明,这可能在这个地方,我们处理Shift键出现:

private void handleShift() {

if (mInputView == null) {

return;

}

Keyboard currentKeyboard = mInputView.getKeyboard();

if (mQwertyKeyboard == currentKeyboard) {

// Alphabet keyboard

checkToggleCapsLock();

mInputView.setKeyboard(mSindhi);

} 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);

}

}

现在我没有任何想法如何摆脱上述异常,并得到我的代码工作。请解决这个问题!

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/22229.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信