在 Edittext 问题上弹出 Arabic/Urdu 自定义键盘

Pop up Arabic/Urdu custom keyboard on Edittext Issue

我正在开发使用 乌尔都语自定义键盘 的应用程序,它工作正常,但问题是当我输入任何单词时,例如(سلام),光标在中间字符处不起作用,例如 cut/copy/paste 或从单词中间删除 (ا) 字符都不起作用。 我使用粗略的技术只是附加字符,但也可以正常工作。

用于录制任何字母

private void addText(View v) {
        // String b = "";
        // b = (String) v.getTag();
        // urdu_word.setText(b);
        if (isEdit == true) {
            String b = "";
            b = (String) v.getTag();
            if (b != null) {
                Log.i("buttonsOnclick", b);
                // adding text in Edittext
                mEt.append(b);
            }
        }
    }

点击后退按钮

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

这里的截图向你们解决了我的问题

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

1) Keyboard-1

2) Keyboard-2

3) Keyboard-3

4) Keyboard-4

我检查了所有这些键盘以及来自库的更多内容,有同样的光标问题,如何通过从中间删除字符来完全管理我的自定义键盘并像使用 EditText 的普通键盘一样复制我的书面文本复制粘贴,提前感谢所有你:)

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

返回按钮

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" />