i have an password edittext with this property :
android:inputType="textPassword"
I want to mask typed chars in edittext with dots but in default way android shows typed chars , how to mask them and prevent to be shown at first (just like html password fields) ?
I think this could be done with a TextWatcher. It's a listener that you would set on your editText. In particular the method 'beforeTextChanged'. You would be able to store off what they have typed internally and replace the string with whatever character you wish.
https://developer.android.com/reference/android/text/TextWatcher.html
Related
I have a design where the editText should have some hidden chars set as password. And after clicking edittext, they should disappear.
Just like this, the circles should be there however once clicked or when eye icon(for making it visible) is clicked, nothing should be there.
android:hint="•••••••"
decided to do so
You need to add these 2 lines in your EditText code;
android:inputType="textPassword"
android:hint="●●●●●●
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 need allow to user input numeric information in a EditText, but the output needs to be formatted like "##.###,##" (# in [0..9]). The formatting I was made in a TextWatcher... this is good, the TextWatcher does the job... bute, when user selects the EditText, as it marked as text, the AlphaKeyboard is shown, if I select the EditText as numeric the keyboard I need is shown and the TextWatcher stop working.
put the following in your xml at the required edittext
<EditText android:inputType="number" ... />
refer to
How do I show the number keyboard on an EditText in android?
You need to change edittext entry like this.
<EditText android:inputType="phone" android:numeric="decimal"></EditText>
Use this code to show soft keypad.
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.showSoftInputFromInputMethod(v.getApplicationWindowToken(), 1);
As you are doing formatting in TextWatcher (##,####....) i.e. you are adding "," in EditText and you have made the EditText as numeric. If its numeric then "," char is invalid. Thus its not allowing TextWatcher to update the formatted text that contains ',".
You have 3 options to deal with this problem :
Make the EditText as normal instead of numeric. In TextWatcher look out for any other invalid chars other than 0-9. You can show IME for Mumber keypad when the focus is on the EditText.
Use Mask for EditText.
Let it be numeric. Trap FocusGain & FocusLost for the EditText. In focusGain, remove the formatting & set the inputType to Numeric. & In focusLost, first make the input type to Normal and then update the entered value to formmated value. You can set the input type to normal at runtime using setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL); & for numeric use : setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
I believe 1st option will be best to handle and manage out.
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 want to get input from user . The inputs are text type such as name email phoneno :
Is EditText is the right way for reading input ?
Also i want to have the title of the input to be displayed like
Name
Email
And the data to be entered after these title.
So is it possible to have my cursor start from right end of the EditText and push characters to left as and when entered.
Also , now when i do gettext , even the title will be part of the read text .
IS there a way to get only the user input from EditText
<EditText android:id="#+id/name" android:layout_height="wrap_content"
android:text="Name" android:inputType="textPersonName"
android:layout_width="fill_parent" android:layout_below="#+id/textview1"
android:textSize="15sp" android:textStyle="bold">
</EditText>
Q: Is edittext is the right way for reading input?
A: Sure. Why not? There are other alternatives, but "EditText" is a good choice.
Q: And the data to be entered after these title. SO is it possible to
have my cursor start from right end of the edittext and push
characters to left as and when entered?
It's customary to pair a TextView (also called a "label" on other, non-Android platforms) next to your EditText. The label is read-only; the EditText field is changeable. Wrap both in a Layout to make sure the "prompt" is adjacent to the "edit":
EditText Label?
for the title, you can use:
-textView above the editText
-in the editText property in the xml, set the android:hint