How do I highlight the underlines of two edittext fields simultaneously? - android

I have two edittext fields. What I want is, when the user types something in second text field, the underlines of both the fields should highlight with the same color.
In the above picture, there are two edittext fields, one for country code and one for mobile no. As you can see, only one field is highlighted, I want both of them highlighted and cursor should remain in the mobile no. field.

You can create a custom view, contains EditText and an underline. EditText has no background, and you can use an ImageView (or a view with right color) as the underline.

Related

EditText - setText on EditText with inputType=numberPassword doesn't show the 'set' text first before the password char

I'm creating a PIN dialog that contains multiple EditText. The behavior I want to achieve is, when the user enter a character, it gets to be shown first before being masked with EditText's password character (bullet/dot).
Instead of managing the multiple EditText, I have a hidden view (EditText) that handles the keyboard input. It's text will then be set to the other EditText that serves as the pin view. However, when I set the value for the pin from the hidden view, the password character is being set right away, no more preview of the set value. The behavior is different when I tried to enter a character directly to the pin view.
How can I achieve the behavior I want with the this current setup? Thanks!
You Can also Achieve This behavior By just using one Editext.
On User Keypress show Current Character for 1 second while all entered characters are shown * if entered.Then replace all text with *,with the length of Text enter inside Edittext.
Basically Toggling The Visible Character with * after 1 second while holding real password inside a variable and then hiding newly entered character by replacing Edittext text with * of variable.length.
I believe what I wanted isn't possible. From what I'm doing the cursor moves to the next EditText when the current received a value.
Using an EditText with inputType (in my case) numberPassword, as soon as the focus was removed from the EditText or if it doesn't have the focus in the first place, setting a value to it will immediately show the 'password' character.

Placeholder hint while typing in EditText in Android

I have an EditText field and the user may only input six digits. When the EditText is focused, it should hint the user that he can only input six digits.
The idea is to display the remaining digits in gray, like this:
When the user inputs a digit, then it appears like this:
(The red vertical bar represents the cursor.)
The cursor should not be positioned behind its current position in both images; the gray digits should only be visible, and should not be selectable.
So in fact I want to set a placeholder text, but retain a part of the placeholder text whilst the user is typing.
I read about the TextInputLayout class from the Design Support library, but I don't know how I can achieve abovementioned idea.
How to do this?
I will give you only the idea, so implementation is up to you. Create your TextWatcher, in
onTextChanged()
Count how many digits user wrote and depending on this number create string padded with zeros. After it, make zeros be of different color
Spannable textWithTintedZeros = new SpannableString(paddedString);
textWithTintedZeros.setSpan(new ForegroundColorSpan(yourGrey), firstZeroIndex, length, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
editText.setText(textWithTintedZeros);
And at last set selection to be before zeros with
editText.setSelection(indexBeforeFirstZero);
Don't forget also to block changing cursor position. I think can be done with
View.OnKeyListener
You could add over the edittext a TextView with gravity right. Then in the listener of edittext (ontextchanged) modify that TextView.
I don't know if you can do it with only EditText.

Get EditText ID in which Cursor is blinking

I have four edit text. And one button .
First:On Click of button I want to set the Button Text to EditText in which cursor is blinking.
Second: After reaching MaxLength character of Edit text automatically set focus to next edit text.
Any Idea how to do that?
Make a list of all TextEdit, then search for selected:
http://developer.android.com/reference/android/view/View.html#isSelected()

Android accessibility feature for TextView

Hi I have a view with a TextView and linear layout. Linear layout is a kind of custom keyboard with number of buttons. So every button click I have to do some validations and append a character to the TextView.
Click of each button I append the character to the textview. Now when I turn the Accessibility feature ON, it is expected to read out the last character that is entered. But what happens is every time I set text in the text view.. Accesibilty feature reads out the 1st char in the textview, not the last char..
so Im confused on how to control the accessiblity of textview.. Can anyone plz tell me how to control the accessibilty.
You could use the setContentDescription() on your TextView to set it to the character you just entered. Then when accessibility kicks in it will ask your TextView for its content description and it should work. See docs here:
https://developer.android.com/reference/android/view/View.html#setContentDescription(java.lang.CharSequence)

Can I have the same EditText box on several Tab screens?

I am using three tabs for my application, with each tab showing a number of edittext boxes used for user input. For user convenience, I have some of the same edittext boxes on each screen so that the user doesn't have to go back to tab1 just to enter a value. For example, I have an edittext box on all three tab screens asking for the user's age. I have named the edittext boxes age1 on the tab1 screen, age2 on the tab2 screen, and age3 on the tab3 screen. Then I use code to read which of the three boxes have a value in it, I copy that value ionto the other two edittext boxes.
Is there a way to keep the same edittext box name in all three screens so that a value typed in one shows up in all three, and a single value can be retrieved with a single age.getValue() command?
Each tab nests an Activity, which is its own context.
Since an EditText requires a Context in its constructor, and will only exist in relation to that Context, you can't use it with multiple contexts.
you dont need a activity for every tab
I think you cant add a view twice (but its worth trying )
or you can make a class that extends the editText class lets name it
make a static list in the class (theList)
in the constructor you add each instance to the list
oweride the on text changed method ( or something similar)
and set the text to every item in the list
{
for(EditText e:theList)
e.setText(this.getText());
}
i other words every instance will have the same text

Categories

Resources