Att*_*lah 5 android android-softkeyboard android-edittext
我在app上工作,我使用乌尔都语自定义键盘工作正常,但问题是当我键入任何单词例如(سلام)时,光标变为不适用于中间字符,例如剪切/复制/粘贴或删除(ا)字符从中间起,单词不起作用.我使用粗略的技术只是附加字符,但也工作正常.
用于录制任何字母
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
用于后退按钮攻丝
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));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用了很多来自github的库和代码但是没有抓住好主意
1)键盘-1

2)键盘-2

3)键盘-3

4)键盘-4
我从libs检查了所有这些键盘和更多,有相同的光标问题,如何通过从中间删除字符完全管理我的自定义键盘和复制我的书面文本复制粘贴像普通键盘与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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
用于添加任意字符
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);
}
}
Run Code Online (Sandbox Code Playgroud)
为了复制粘贴,我向 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" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |