Saturday, November 17, 2012

Make Android Edit text field allows only for selected characters

There is a simple method to make a restrict or a limit on allowed characters in Android edit text field.
Eg: Suppose that you want to make a restrict where user only allows to type  a,e,i,o,u. You can easily do this by using following line in your layout.xml file
android:digits="aeiou"

Eg: (I used edit text in relative layout)
     <EditText
         android:id="@+id/editText1"
         android:digits="aeiou"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:layout_marginLeft="54dp"
         android:layout_marginTop="123dp" >
         <requestFocus />
     </EditText>

2 comments:

  1. Ι every time uѕеd to read pіecе of ωriting in newѕ pарers but now аѕ I am а uѕer of inteгnеt
    therefoгe from noω І аm uѕing net fог artісles, thаnks to web.
    Stop by my website : http://www.web-systems.pl/

    ReplyDelete
  2. Askіng questions are truly pleaѕant thing if you аre not
    undеrstanding something completely, hoωevеr this poѕt presеnts good
    undeгstanding even.
    Feel free to surf my page web-systems.pl

    ReplyDelete