在Edittext问题上弹出阿拉伯语/乌尔都语自定义键盘

时间:2015-09-12 07:27:03

标签: android android-edittext android-softkeyboard

我在使用乌尔都语自定义键盘的应用程序工作正常,但问题是,当我输入任何单词时,例如(سلام),光标变为不适用于中间字符,例如剪切/复制/粘贴或删除(ا)字符从中间字不起作用。 我使用粗略的技术只是附加字符,但也工作正常。

用于录制任何字母

private void isBack(View v) {
        if (isEdit == true) {
            CharSequence cc = mEt.getText();
            if (cc != null && cc.length() > 0) {
                {
                    mEt.setText("");
                    mEt.append(cc.subSequence(0, cc.length() - 1));
                }
            }
        }
    }

用于后退按钮

{{1}}

此处的屏幕截图清除了我的问题 opened the issue

我使用了很多来自github的库和代码,但没有抓住好主意

1) enter image description here Keyboard-1

2) enter image description here Keyboard-2

3) enter image description here Keyboard-3

4) enter image description here

我从libs检查了所有这些键盘和更多,有相同的光标问题,如何通过从中间删除字符来完全管理我的自定义键盘并复制我的书写文本复制粘贴像普通键盘与EditText,感谢你们所有人: )

Keyboard-4

1 个答案:

答案 0 :(得分:0)

感谢上帝我使用简单的逻辑解决了我的问题。

对于后退按钮

private void isBack(View v) {
        // char[] tempChar = null;
        if ((mEt.getText().toString().length() > 0)) {
            int temp = mEt.getSelectionEnd() - 1;
            if (temp >= 0) {
                mEt.setText((mEt.getText().toString()
                        .substring(0, mEt.getSelectionEnd() - 1).concat(mEt
                        .getText()
                        .toString()
                        .substring(mEt.getSelectionEnd(),
                                mEt.getText().length()))));
                mEt.setSelection(temp);
            }
        }
    }

添加任何字符

private void addText(View v) {
        int temp = mEt.getSelectionEnd();
        if (temp >= 0) {
            String b = "";
            b = (String) v.getTag();

            mEt.setText((mEt.getText().toString()
                    .substring(0, mEt.getSelectionEnd()) + b.concat(mEt
                    .getText().toString()
                    .substring(mEt.getSelectionEnd(), mEt.getText().length()))));
            mEt.setSelection(temp + 1);
        }
    } 

复制粘贴我在EditText中添加了几行代码

    <EditText
        android:id="@+id/xEt"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:background="@drawable/edittextshape"
        android:ems="10"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="top"
        android:imeOptions="actionDone"
        android:padding="15dp"
        android:singleLine="false"
        android:visibility="visible" />
相关问题