Questions tagged [android-textwatcher]

For questions related with TextWatcher callback interface

A special interface, that allows watching of the Editable field contents.

Has three callback methods:

  • void afterTextChanged (Editable s)
    This method is called to notify you that, somewhere within s, the text has been changed.
  • void beforeTextChanged (CharSequence s, int start, int count, int after)
    This method is called to notify you that, within s, the count characters beginning at start are about to be replaced by new text with length after. It is an error to attempt to make changes to s from this callback.
  • void onTextChanged (CharSequence s, int start, int before, int count)
    This method is called to notify you that, within s, the count characters beginning at start have just replaced old text that had length before. It is an error to attempt to make changes to s from this callback.

Useful links

205 questions
0
votes
0 answers

Prevent user from pasting more than x characters in EditText but allowing them to type as many characters as they want

I know that limiting the text length of EditText can be done using the maxLength attribute in xml or using InputFilter using the below approaches Using xml android:maxLength="10" Using InputFilter myEditText.filters =…
varunkr
  • 5,364
  • 11
  • 50
  • 99
0
votes
0 answers

Setting spans "on-the-go" in EditText using TextWatcher

I want to set spans while user is typing. I have configured interface for choosing which span to apply, but I'm having problems with spans setting. When I'm setting span on the whole word it works properly, but I can't remove text style by putting…
Andrey Orel
  • 45
  • 1
  • 5
0
votes
0 answers

How to get value from user in recycler view and edit the value?

I want to create a recipe application, I the user to add the ingredients by creating only one Edit text, and every time the user press enter I want to show the item above the Edit text horizontally. user also can edit the item for example delete…
0
votes
1 answer

How to disable one edittext when we start typing other editext in android?

I have a form with two editext and condition is only one should be enable when we enter value to any of edittext e.g We have 2 edittexts ...Edittext1 and Editext2 case 1: When we type edittext1 then editext2 should be disable and greyout. Case 2 : …
0
votes
0 answers

TextWatcher class trims space from end when spacebar is pressed and cursor moves to beginning of editText

Below is my textWatcher class: class MyTextWatcher(private val editText: EditText) : TextWatcher { override fun beforeTextChanged( s: CharSequence?, start: Int, count: Int, after: Int ) { } override…
0
votes
1 answer

Get data from list of EditTexts in a recycler view to a list?

I am having an EditText in a TTextInputLayout as a Row_item for my recycler view, On the click of a button I am incrementing the count value in that recycler view and adding the edit text views in the app. After having as many views as I want, I am…
0
votes
2 answers

How to use textwatcher to enable validation button in kotlin?

I want the editText firstname and the email field editText to be filled in correctly. The validation button which is disabled initially should become enabled (especially for the email address in name@blabla.com format). I tried with textWatcher but…
0
votes
1 answer

Android Studio TextWatcher attributes names issue

I'm actually following a class on creating my first android application with Android Studio. I need to use TextWatcher, and obtain something like this : mNameEditText.addTextChangedListener(new TextWatcher() { @Override public void…
0
votes
2 answers

How to disable textwWatcher when I use EditText.setText()?

I am working in an android studio project where I am trying to make a number system convertor app. I have used 2 EditTexts (Binary and Decimal). APP SCREENSHOT Here I want that whenever user give a input to decimal EditText, its corresponding value…
0
votes
0 answers

when text is fully highlighted in one color switch activity

i am recreating a typing app for education purposes. The goal is to type the words of the paragraph. When a word is correct the word turns green, the editText field get cleared and its the next words turn. At the end every word is green and than the…
0
votes
1 answer

Make few prefilled characters uneditable in EditText using Android

I am working on EditText where I am displaying pre filled country code in start lets say "+971", what I want is that if user trying to click and edit in EditText, he should not edit or delete "+971" and can only be able to put number after that like…
Usman Khan
  • 3,739
  • 6
  • 41
  • 89
0
votes
1 answer

How to fix java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1

I need help here. So I've been tinkering with android studio and my app crashes everytime I type something in a textfield using onTextChanged and it prints this error in logcat java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1. How do I…
0
votes
4 answers

How do you change an EditText on Android based on specific values inputted?

I want the user to change some device settings, for example run an alarm after X seconds (default 5s). I want the user to be able to type in what they want (number value from the edit text), but if the value they put in is not between 2s and 20s, I…
0
votes
2 answers

How to make a formated EditText start from Right to Left using TextWatcher?

What I have: I have an EditText which accepts decimal input and I setted the default value in the XML to 0.00 (if there is no input yet) If the user press 1, then the value change to 1. If he needs to enter decimal value then he must press the dot .…
Félix Maroy
  • 1,389
  • 2
  • 16
  • 21
0
votes
1 answer

How to use textwatcher for police number

I have the pattern of number police like this "^[A-Z]{1,2}\s\d{1,4}\s[A-Z]{1,3}$" How to implement that pattern tobe text watcher on edit text. I want to fill in the automatic edit text according to the format