Questions tagged [textwatcher]

TextWatcher is an interface in the Android SDK that can be attached to an Editable object to see when that Editable's text changes.

The android.text.TextWatcher Java interface is implemented by objects attached to an widget on . It exposes three methods, each of this methods will be called at a certain moment of the text being modified (for example: after the text is changed). Care must be taken when using the TextWatcher's methods to avoid getting into an infinite loop or to incorrectly modify the text.

617 questions
127
votes
13 answers

How to use Single TextWatcher for multiple EditTexts?

I have three EditText widgets in my view layout. Is there a way to use a single TextWatcher for all three EditTexts?
bie
  • 1,279
  • 2
  • 9
  • 3
127
votes
9 answers

android edittext onchange listener

I know a little bit about TextWatcher but that fires on every character you enter. I want a listener that fires whenever the user finishes editing. Is it possible? Also in TextWatcher I get an instance of Editable but I need an instance of EditText.…
prongs
  • 8,944
  • 19
  • 61
  • 104
110
votes
9 answers

How to use the TextWatcher class in Android?

Can anyone tell me how to mask the substring in EditText or how to change EditText substring input to password type or replace by another character like this 123xxxxxxxxx3455 String contents = et1.getText().toString(); …
Android developer
  • 1,229
  • 2
  • 9
  • 6
73
votes
16 answers

TextWatcher for more than one EditText

I want to implement the TextWatcher interface for more than one EditText fields. Currently I am using : text1.addTextChangedListener(this); text2.addTextChangedListener(this); then overriding the methods in my Activity: public void…
Vikas Patidar
  • 41,230
  • 22
  • 89
  • 104
68
votes
17 answers

How can I do something 0.5 seconds after text changed in my EditText control?

I am filtering my list using an EditText control. I want to filter the list 0.5 seconds after the user has finished typing in EditText. I used the afterTextChanged event of TextWatcher for this purpose. But this event rises for each character…
Bobs
  • 21,870
  • 33
  • 134
  • 221
63
votes
13 answers

How to remove all listeners added with addTextChangedListener

I have a ListView where each row has an EditText control. I want to add a TextChangedListener to each row; one that contains extra data which says which row the EditText was in. The problem is that as getView gets called, multiple TextWatchers are…
GendoIkari
  • 11,134
  • 6
  • 58
  • 100
59
votes
5 answers

Detect if content of EditText was changed by user or programmatically?

I would need a way to detect if the EditText has been changed by the user typing something or by the app changing the text programmatically. Any standard way of doing this? I guess I could always do something hackish like unsetting the TextWatcher…
Magnus W
  • 11,902
  • 10
  • 61
  • 135
56
votes
10 answers

How to mask an EditText to show the dd/mm/yyyy date format

How can I format an EditText to follow the "dd/mm/yyyy" format the same way that we can format using a TextWatcher to mask the user input to look like "0.05€". I'm not talking about limiting the characters, or validating a date, just masking to the…
Juan Cortés
  • 18,689
  • 8
  • 63
  • 88
48
votes
5 answers

Differences between TextWatcher 's onTextChanged, beforeTextChanged and afterTextChanged

In my Android project, I have had to add a TextChangedListener (TextWatcher) to an edit text view. And there are three parts to it: onTextChanged() beforeTextChanged() afterTextChanged() What are the differences of these three? I have had to…
Samantha Withanage
  • 3,471
  • 10
  • 25
  • 56
47
votes
7 answers

TextWatcher events are being fired multiple times

I have an annoying problem with TextWatcher. i've been searching the web but couldnt find anything. appreciate if someone could assist me. For some reason the calls to the TextWatcher events upon one text change are erratic. sometimes they are being…
AsafK
  • 2,901
  • 3
  • 26
  • 35
38
votes
2 answers

Android intercept paste\copy\cut on editText

How can I intercept this kind of events ? I need to add some logic when the user trying to paste some text into my EditText i know i can use TextWatcher but this entrypoint not good for me becuase i only need to intercept in case of paste and not…
and_dev
  • 1,403
  • 3
  • 14
  • 17
29
votes
7 answers

How to Apply the Textchange event on EditText

I developed one simple app, like subtraction, addition. In this app I use three EditTexts, one for answer and other two for question. I want to calculate the answer of question on text change event. But when I apply the text change event on both of…
Zala Janaksinh
  • 2,871
  • 5
  • 29
  • 58
23
votes
2 answers

Inner Class inside an Interface implementing same Interface, what we are achieving by this?

My Question: I was looking at the source code of TextWatcher and I didn't get the concept here. What was the point of extending to NoCopySpan? TextWatcher.java: public interface TextWatcher extends NoCopySpan { public void…
Hisham Muneer
  • 8,084
  • 8
  • 49
  • 77
18
votes
4 answers

Implementing Text Watcher for EditText

I have an EditText. When i click on it, it becomes focusable. I will type the input text to be entered into the EditText. I want to implement a listener for EditText, so that when i stop typing, it should automatically save that text into the…
Santhosh_pulliman
  • 2,059
  • 6
  • 30
  • 46
17
votes
2 answers

How to get the View in TextWatcher method context?

I have a handler that is a TextWatcher and i dont know how to get the View that has changed text. Here is my handler: TextWatcher handler = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int…
Paulo Roberto Rosa
  • 2,643
  • 2
  • 24
  • 52
1
2 3
41 42