2015-09-12 12 views
6

Pracuję nad aplikacją, w której używam Urdu Custom Keyboard jej praca jest w porządku, ale problem polega na tym, że kiedy wpisuję dowolne słowo, np. (سلام), kursor nie będzie działał na środku znaku, na przykład wycinanie/kopiowanie/wklejanie lub usuwanie (ا) znaku od środka od słowa nie działa. Używam nieobrobionej techniki, tylko dołączanie znaków, ale działa też dobrze.Wyskakująca niestandardowa klawiatura arabska/urdu na Edittext Issue

Dla taping dowolny alfabetycznej

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

Na tylnym przycisku spustu

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

Oto zrzut wyczyścić mój problem do was ludzie enter image description here

Kiedyś dużo biblioteki i kodu z github ale nie złapać dobry pomysł

1) Keyboard-1 enter image description here

2) Keyboard-2 enter image description here

3) Keyboard-3 enter image description here

4) Keyboard-4

Sprawdziłem wszystkie te klawiaturę i więcej z bibliotekami, mają ten sam problem kursor, jak w pełni zarządzać niestandardową klawiaturę poprzez usunięcie znaku z połowy i skopiować moją pisemną kopię tekstu wklej jak normalnej klawiaturze EditText, z góry dzięki was wszystkich :)

enter image description here

Odpowiedz

0

Dzięki Bogu mi rozwiązać mój problem, stosując prostą logikę.

Na tylnym przycisku

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

Aby dodać dowolny znak

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

pasty do kopiowania i dodaje kilka linii kodu do 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" /> 
Powiązane problemy