-1

in the below EditText I want to allow some characters like @, -, _, . (dot) remaining characters I don't want to allow to enter. Even want to block smiley's.

Can any one help me?

<EditText
     android:id="@+id/emailId"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:background="@color/transperent"
     android:hint="@string/email_id" 
     android:digits="0123456789*qwertzuiopasdfghjklyxcvbnm_-." 
     android:inputType="text"
     android:maxLines="1"
     android:padding="8dp"
     android:textColor="@color/white"
     android:textColorHint="@color/white" />
Rikalous
  • 4,514
  • 1
  • 40
  • 52
jyo cha
  • 71
  • 9

2 Answers2

0

You can try use digits and just put there every char that you allow , for example all the english chars:

android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " 
Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
0

Build.gradle (Module:app)

dependencies{
        compile 'com.xw.repo:xedittext:2.0.0@aar'
    }

XML:

<com.xw.repo.XEditText
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:inputType="text"
    android:layout_height="wrap_content"
    android:digits="0123456789qwertzuiopasdfghjklyxcvbnm_-." //Digits specific
    app:x_disableEmoji="true"/> // Disable Emoticons

I hope it helps

MarcosApps
  • 414
  • 2
  • 4
  • 15