In my android application, I have some EditTexts. Those EditTexts will serve as password fields, but I've not marked them as password fields in the attributes, so that the font of hint text matches the font of hint in normal EditText widgets.
The problem I have though is that the password is revealed in the keyboard suggestion while it is typed, although it is hidden as I've used:
EditText.setTransformationMethod(new PasswordTransformationMethod());
What should I do to disable those suggestions?
I had already fixed it, but didn't have time to come and answer the question.
For anyone who is struggling with this, adding the following attribute to the EditText will work:
android:inputType="textNoSuggestions"
Did you use android:inputType="textPassword"
and android:password="true"?
Related
When inputtype is used as textPassword, user was able to entire emoji in edit text. If I use both textpassword and textEmailAddress, then passwords are visible. Is there any easy way to achieve this without using textwatcher. The password field can allow other special characters also.
Please note that I am trying to remove emoji by setting the input type. I am not looking for solutions with regular expressions/textwatcher/filters. If the field is not password type I would have used textEmailAddress to avoid emoji option on keyboard
This allow character only a to z and A to Z :
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
android:inputType="textPassword"/>
Use this in your Password EditText XML file
android:inputType="textPassword|text"
Look more about input methods here
Also, you can use RegularExpression to check whether your password is valid or not.
I want to remove the underlines from texts inside edittext fields.
How can I do that?
You can do it with following code. Just paste it in layout of EditText.
android:inputType="textNoSuggestions"
In order to get rid of spell checking you have to specify the EditText's InputType in the XML as the following:
android:inputType="textNoSuggestions"
However, if your EditText is multiline and also you need to get rid of spell checking,then you have to specify the EditText's InputType in the XML as the following:
android:inputType="textMultiLine|textNoSuggestions"
Minor addition to Chintan's answer - such (and other) combination is also allowed:
android:inputType="textCapSentences|textNoSuggestions"
Or if you want to just disable the red underline (and the autocorrect dialog), you can override the isSuggestionsEnabled() method on TextView.
This will keep the keyboard autocomplete working.
I just Added a line in for EditText
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
and it worked fine for me.
So I was not able to find out any direct way of doing it. So went ahead with below workaround:
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
As the input type becomes a visible password, even if the spell check is enabled from the device settings, the Red underline won't appear. :)
In Android, while entering password the text is displayed. Is there any way to hide the text programmatically?
Set the inputType to password. Either in the xml (as an attribute of your EditText):
android:inputType="textPassword"
or in your program:
yourETView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
In your XML that holds the input field use the following:
android:inputType="textPassword"
it's depend on the real device. means In device whatever the user use the devices have 1 one option was available in the setting for hide/show the text while typing text in password field so no need to worry about it, for accept text as password you can set the input type of edittext like this way
android:inputType="textPassword"
in xml layout file
I have a problem with TextEdit,
if I do editText.setInputType(InputType.TYPE_NONE); the user is not able to type anything.
Anyway, if there is a physical keyboard attached, then the user can type by using it (of course the soft keyboard doesn't work).
Is there any way to fully disable editing on a EditText?
PS: I need to do that programmatically at runtime
Try
android:editable="false"
in xml layout file
android:editable="false" is deprecated ,prefer not to use it.
Another solution to this that I used is given below
first_password_EditTextBox = (EditText) findViewById(R.id.editText1);
first_password_EditTextBox.setEnabled(false);
Just wondered, am I the only one to encounter this "strange" behavior.
When placing an EditText inside my activity and setting its
inputType="textPassword" as follow:
<EditText android:text="" android:id="#+id/EditText01"
android:hint="This is a hint" android:inputType="textPassword"
android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
The hint is displayed with bigger/double spaces between the words.
If I remove the inputType attribute it all goes back to normal.
I couldn't find a known issue regarding this behavior.
BTW- If you wonder why this is important (it isn't that much) try
putting two EditText widgets one below the other and set the inputType
of one of them to "textpassword" it doesn't look good.
Any idea on how to change the password or the other edittexts to use the same format ?
Thanks
PS. The question was added here first: http://groups.google.com/group/android-developers/browse_thread/thread/88738bb8d8046f6f but I didn't find an answer.
It happens because typeface automatically setted to monospace in case of password field. Setting android:typeface="normal" on password field doesn't helps.
Here code from TextView sources:
if (password) {
setTransformationMethod(PasswordTransformationMethod.getInstance());
typefaceIndex = MONOSPACE;
} else if ((mInputType&(EditorInfo.TYPE_MASK_CLASS
|EditorInfo.TYPE_MASK_VARIATION))
== (EditorInfo.TYPE_CLASS_TEXT
|EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
typefaceIndex = MONOSPACE;
}
I can't find solution without implementing custom control with overriden typeface for hint.
P.S.: There is one solution, but it is not always acceptable - to set typeface to monospace on other EditText's.
Doing mEditText.setTypeface(Typeface.DEFAULT); fixes the problem for me.