Search code examples
androidandroid-edittextandroid-keypad

How to avoid showing characters like Ä in android keyboard


I am stuck in an issue where one of my user entering characters like Ä in an edittext and I am preparing an XML from that data. Due to encoding issue I can't prepare a valid XML from these kind of characters. Is there anyway I can stop user to enter such kind of characters or can I hide these characters from android default keyboard itself ?

Regards


Solution

  • you can restrict the user to enter only specific characters in the edit text like below,

    <EditText
        android:id="@+id/YourEdittextId"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textNoSuggestions"
        android:privateImeOptions="nm"
        android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" />
    

    Above code restrict user to enter only English digits, letters and space