AhmedAdel
AhmedAdel

Reputation: 15

Android How to enable writing In Arabic In EditText

I have Search Box Edit Text. How can I write Arabic text to return results. Note : In English language Edit Text is working fine and return results .

Upvotes: 1

Views: 2169

Answers (2)

Safeer
Safeer

Reputation: 1467

I got my language text working in Edittext by creating my own keyboard. Here is a great tutorial about creating your own keyboard. In this the tricky part would be to know the ASCII codes of Your language (Arabic) characters. And once you have them, use them in your keyboard.xml.

After that you have to use your own keyboard in your layout.

<android.inputmethodservice.KeyboardView
    android:id="@+id/keyboard_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ads_include"
    android:background="@color/colorKeyboardBackground"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:keyBackground="@drawable/key_backgrounds"
    android:keyTextColor="@color/colorPrimaryDark"
    android:shadowRadius="0.0"
    android:visibility="gone" />

And map your created keyboard on this view as:

Keyboard keyboard = new Keyboard(MainActivity.this, R.xml.english_view);
keyboardview.setKeyboard(keyboard);

Now you are set to play with your own keyboard in your EditText. And for hiding system keyboard and showing yours use this code:

  public void showCustomKeyboard(View v) {
    keyboardview.setVisibility(View.VISIBLE);
    keyboardview.setEnabled(true);
    if (v != null) {
        ((InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(v.getWindowToken(), 0);
    }
}

Here v will be your Edittext. Chill!

Upvotes: 1

JAD
JAD

Reputation: 1160

"Edit Text" allows adding / searching Arabic characters or any other language. The results might not returning because of your server or the search provider doesn't support search in Arabic.

Upvotes: 0

Related Questions