jimmy jimmy - 3 months ago 14
Android Question

How to convert uppercase letter to lowercase?

I am creating one application,in my login page i am able to enter uppercase and lowercase letters both,what i want is if user enters letters in uppercase it should convert to lowercase,in short i dont want to allow user to enter uppercase letters

<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/f_name"
android:gravity="center"
android:hint="EMAIL"
android:inputType="textEmailAddress"
android:textColor="#676767"
android:textSize="20sp"

/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/email"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:background="@drawable/f_name"
android:gravity="center"
android:hint="PASSWORD"
android:inputType="textPassword"
android:textColor="#676767"
android:textSize="20sp"

/>


Code

etemail = (EditText) findViewById(R.id.email);

etemail.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE);

Answer

In the XML, add this for your edittext,if you want to restrict the user to input lowercase only.

android:digits="abcdefghijklmnopqrstuvwxyz "

OR

android:digits="abcdefghijklmnopqrstuvwxyz1234567890 "

if you also want to allow to input numbers.

Comments