Android xml phone number in keyboard restriction - android

Hi in my project i have a edit text box, where i want the user to enter his phone number, I need it in a format like +0000000000 no need to allow - or any other symbols. I need to restrict the user while entering in keyboard. I have implemented the regular expression for validation for this format and I am using android:inputType="phone" is there any other input Type is available or can i customize it in any way. Looking for help pls...

Try it android:digits="+0123456789"

try this::
android:inputType="number"
it allow user to enter only integer value

Related

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
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
Hide suggestion string in your edittext.
android:inputType="textFilter"
Few days before I was facing same issue I solved this by creating below method.
public static String stripSpecialUTFChars(String string) {
return string.replaceAll("\u0080", "");
}
Please pass your String to above method and use this like below
textView.setText(Html.fromHtml(stripSpecialUTFChars(yourString)));
actually this issue is due to UTF characters.

Input type "textVisiblePassword" vs "text": what's the difference?

Short and sweet: I have no idea what the difference between textVisiblePassword and text is, in regards to inputType on an EditText. According to the docs, textVisiblePassword is "text that is a password that should be visible", where password is unhelpfully "text that is a password".
What's the diff? Why use textVisiblePassword?
Using textVisiblePassword type explicilty tells software keyboard, that content of this field should not be added to any vocabulary, synchronized through network, added to usage statistics or anything like this. It still makes sense to use it for sensitive data, like logins - not exactly secret, but nothing you would share.
when we setup textPassword input type on edit text. textVisiblePassword inputtype is used when we want to have show password option. This option will make the password readable whereas text inputtype won't do this

android edittext limit to text and numbers

I am creating an android application. The first thing I'm creating is a login activity. I am trying to limit the username edittext just to text/numbers only (no special characters). Is there a way to adjust this in the xml file?
I dont think you can limit the characters from xml. You could always use a InputFilter, but specifically android provides UsernameFilterGeneric to filter valid user names. You could also use UsernameFilterGMail
As you already use in java Regular expression.called the same class here for checking for particular field.
let me know if you want some more if you didn't know about the RE.

how to get soft keypad to write email id in edittext in android

I am using android:phoneNumber to open soft keypad to get phone number in android.I want to open keypad which contains all key required to write email id in edittext.So is there any solution for this(email) like phone number.
Thank you
Use textEmailAddress (0x00000021) as defined here: http://developer.android.com/reference/android/widget/TextView.html
In Java code:
myEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
In XML properties:
android:inputType="textEmailAddress"
you can set property Input Type for EditText
use the below code for getting the email soft keyboard
Editetxt email=(EditText)findViewById(R.id.edotetxtemail)
email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);

How to setup my EditText xml in Android

For allow user only can input lower case alphabet and number, how can I setup my EditText in a xml file ?
Sorry, I did not provide clear information. I just want to filter or check user's input.
AFAIK, your question is complicated to do. better get a input from user. then you can convert that string to lowercase using toLowerCase().

Categories

Resources