I have the following:
<EditText
android:inputType="number"
android:password="true"
....
</EditText>
I'm getting a warning that "android:password" is deprecated and that I should use inputType instead. Is there a way to specify inputType as number and password?
Set android:inputType="numberPassword"
See this Link
you should use TYPE_CLASS_NUMBER.
EDIT:
As this answer
android:inputType="textPassword|number"
ignore textPassword and only accept number but not password.
So you should use android:inputType="textPassword|number" with android:password="true".
that seems to be the only solution.
Just set your input type to this android:inputType="textPassword|number"
Related
I created a custom edit text, but something is weird, I can choose every input type for it except password type, I already try with input type TYPE_TEXT_VARIATION_PASSWORD, TYPE_TEXT_VARIATION_WEB_PASSWORD and also with transformationMethod PasswordTransformation(), rawInputType and with maxlines = 1 too! But nothing, I can set by code the text for my edit text and that appears in emulator as password format but when I focus to continue writing, all transforms to normal input type text. I don't know why. Someone can help me?
SOLUTION
I finally found the solution, the problem was that I put the attribute single line true, and it seems that password input type and transformation method only works with maxlines, so I have only to erase that and done. Thanks all!
Try android:inputType="textPassword":
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
tools:text="12345" />
Programatically:
password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
Or:
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
try this
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
tools:text="aaaaa" />
SOLUTION
I finally found the solution, the problem was that I put the attribute single line true, and it seems that password input type and transformation method only works with maxlines, so I have only to erase that and done. Thanks all!
Only change the éditent type input on XML file or JAVA file
XML
android:inputType="mySecret"
JAVA
password.setInputType( InputType.TYPE_TEXT_VARIATION_PASSWORD);
I've the following EditText which it's characters need to be hidden as it is a password. I can do this with the following.
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Please Enter Password/Pin"
android:inputType="textPassword"
>
I would like to set the keyboard to numeric as all passwords are numbers, but when i do the following the numbers are displayed. How can i acheive both?
passwordPin = (EditText)findViewById(R.id.password);
passwordPin.setInputType(InputType.TYPE_CLASS_NUMBER);
Try this.
android:inputType="textPassword|number"
Try the following line for EditText
android:inputType="textPassword|number"
Looking through Eclipse, you can also use the following, not sure how backwards compatible it is however.
android:inputType="numberPassword"
Solved.
android:inputType="textPassword|number"
android:password="true"
You can do it programmatically as long as password is now deprecated. Try this:
passwordPin = (EditText)findViewById(R.id.password);
passwordPin.setInputType(InputType.TYPE_CLASS_NUMBER);
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
I ran into this same requirement and solved it this way:
In XML:
android:inputType="number|numberPassword"
Programmatically:
editText.setInputType(InputType.TYPE_CLASS_NUMBER || InputType.TYPE_NUMBER_VARIATION_PASSWORD)
Hope this helps :D
I have been trying to restrict the password field with a set of characters. So tried to use the textFilter and done it. When i set inputType textFilter and textPassword, it stops displaying as password dots and shows the text that i type in the Editext. When i remove the textFilter, then characters of the field are displayed as password dots instead of themselves.
This is the snippet in used in my XML resource
main.xml
<EditText android:id="#+id/password" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="2.0dip" android:singleLine="true"
android:scrollHorizontally="true" android:inputType="textPassword|textFilter"
android:hint="#string/input_field_here" android:digits="#string/only_alpha_numeric"></EditText>
string.xml
<string name="only_alpha_numeric">abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ/>
Please let me know , is there any possible way to achieve my desired result ?
Thanks
Hi use following lines in xml file . From this you can keep the textFilter property as well as password hint property too.. hope this will help you a lot.
android:password="true"
android:inputType="textFilter"
I have the following:
<EditText
android:inputType="number"
android:password="true"
....
</EditText>
I'm getting a warning that "android:password" is deprecated and that I should use inputType instead. Is there a way to specify inputType as number and password?
Set android:inputType="numberPassword"
See this Link
you should use TYPE_CLASS_NUMBER.
EDIT:
As this answer
android:inputType="textPassword|number"
ignore textPassword and only accept number but not password.
So you should use android:inputType="textPassword|number" with android:password="true".
that seems to be the only solution.
Just set your input type to this android:inputType="textPassword|number"
I'm trying to define an EditText but this warning is shown:
This text field does not specify an inputType or a hint.
The code in main.xml is:
<EditText android:id="#+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/textTest" />
How can I fix it?
You could add a hint :
android:hint="This will appear to the user if he didn't enter something yet in the EditText"
and a inputType so you could present to the user a better suited soft keyboard for the text he is suposed to enter in the EditText:
android:inputType="number"
will present a soft keyboard with only numbers and various signs.
Those are just warnings, you could ignore them but is better for the user to implement them.
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
>
I think You should add input type.......
This is a known issue. Sometimes it doest work with changing to:
android:inputType="text"
I got it to work by setting:
android:inputType="textNoSuggestions"
Hope this helps
Above all are the solutions but before that you should understand what does that warnig mean.
Hint:- Hint is the text shown to user before writing anything over.
For eg. if you are putting a edittext where you want user to add his
name then you can write
<Edittext
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Enter Name"/>
Input Type:- This is the xml tag that is to be used within edittext to let edittext to follow that particular restriction. if you are giving inputtype:number then user would be able to enter only numbers. There are several input type fields are there for that you can refer official developer site.