Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the android:inputType="phone" to android:inputType="textEmailAddress" from java?

Tags:

android

Im a beginner in android and need your advice:

1. The app is about to send a message (sms or email) using two radio buttons (SMS or Email).

2. When initiating, the SMS radio button will be checked and the EditText for the contact/receiver is on android:inputType="phone"

3. If i click on the EMAIL radio button i would like the EditText to be changed to android:inputType="textEmailAddress"

how can i do this from the MainActivity.java?

like image 959
user1653685 Avatar asked Dec 05 '25 23:12

user1653685


2 Answers

You can do that by using this method :

et.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
like image 121
Aprian Avatar answered Dec 07 '25 16:12

Aprian


Try this, it might help you

editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
like image 27
Jithu Avatar answered Dec 07 '25 17:12

Jithu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!