Choose Arabic / Urdu user keyboard on Edittext Issue

I am working on an application in which I use a special Urdu keyboard , its work is great, but the problem is that when I type any word, for example. (سلام), the cursor does not work in the middle of a character, for example, cut / copy / paste or delete (ا) a character from the middle of a word does not work. I use a crude technique, just adding characters, but it also works great.

To write any letters

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

To press the back button

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

Here's a screenshot to clear my problem for you. enter image description here

I used a large library and code from github but didn't catch a good idea

1) Keyboard-1 enter image description here

2) Keyboard-2 enter image description here

3) Keyboard-3 enter image description here

4) Keyboard-4

I checked all of these keyboards and much more from libs, had the same cursor problem how to fully control my user keyboard by removing the character from the middle and copying my copied text copy like a normal keyboard with EditText, in advance all of you in advance :)

enter image description here

+6
source share
1 answer

Thank God I solved my problem using simple logic.

For back button

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

To add any character

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

to copy paste I added a few lines of code in 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" /> 
0
source

All Articles