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.

625 questions
10
votes
2 answers

How to make TextWatcher wait for some time before doing some action

I have an EditText to filter the items in the ListView below it, which may contain more than 1000 items usually. The TextWatcher is: txt_itemSearch.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int…
9
votes
3 answers

Permit only 1 character in EditText and always overwrite when user input it

I need to make an EditText which would accept only one character and only character (letter/alpha). And if user enters other char, it should replace existing one (like overwrite method of text input with 1 allowed symbol). I know how to set the max…
Stan
  • 6,511
  • 8
  • 55
  • 87
9
votes
2 answers

IndexOutOfBoundsException on a textwatcher

I am using a textwatcher to check the validity of an user input. Some of my user had a crash caused by this textwacher. Here is the stacktrace given by google : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1 at…
Laetan
  • 879
  • 9
  • 26
8
votes
7 answers

How to delete instantly SPACE from an edittext if a user presses the space?

I have an edittext, and a textwatcher that watches if SPACE arrived or not. If its a SPACE I would like to delete that instantly. Or if its a space I want to make sure it doesnt appear but indicate somehow (seterror, toast) for the user that space…
Jani Bela
  • 1,660
  • 4
  • 27
  • 50
8
votes
4 answers

Detect changes in EditText (TextWatcher ineffective)

I need to detect text changes in an EditText. I've tried TextWatcher, but it doesn't work in a way I would expect it to. Take the onTextChanged method: public void onTextChanged( CharSequence s, int start, int before, int count ) Say I have the text…
Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
8
votes
2 answers

Using default method raises AbstractMethorError in Android release build

I have an interface that inherits from Android's TextWatcher to only implement afterTextChanged method. I have enabled Java 8 support in my project, and added source and target compatibility options in build.gradle file, but even though it works…
8
votes
2 answers

TextWatcher called even if text is set before adding the watcher

in an android activity, i first recover the text in an EditText and add then a TextWatcher to it. private static int WC = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("TextWatcherTest", "onCreate:\t"…
SimonSays
  • 10,867
  • 7
  • 44
  • 59
8
votes
1 answer

Dynamic mask using TextWatcher?

I'm trying create mask using EditText with TextWatcher. This mask need format a phone number but the problem is I have two situations to this mask. Situation 1 the mask need has 13 digit (99)9999-9999 and situation 2 need has 14 digit…
FernandoPaiva
  • 4,410
  • 13
  • 59
  • 118
7
votes
2 answers

Removing TextChangedListener then re-adding it

So I've been trying to implement the TextWatcher for Android and ran into a few problems with the TextChangedListener being called multiple times or going into an infinite loop as I want to convert the text in the EditText widget into a currency…
Jason
  • 519
  • 6
  • 14
7
votes
2 answers

How to know a delete operation occurred in EditText in Android?

I want to get a callback when a character is deleted in an EditText. How can I do It?
PhillyTheThrilly
  • 1,562
  • 2
  • 16
  • 21
7
votes
4 answers

EditText validation with TextWatcher

I have a Dialog with a EditText and a button. This EditText will name the database table I will create so its of the utmost importance it is validated. So i would like to pose 2 questions: 1) This is quite simple, but i couldn't fin it anywhere:…
Tivie
  • 18,864
  • 5
  • 58
  • 77
7
votes
1 answer

EditText addTextChangedListener only for user input

I have an EditText where I listen for changes in text: editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public…
user1583209
  • 1,637
  • 3
  • 24
  • 42
7
votes
2 answers

Android stackoverflow using while loop

I'm using this method to shrink TextView text as it's name suggests: public static float shrinkTextToFit(String caller, float availableWidth, TextView textView, float startingTextSize, float minimumTextSize) { startingTextSize =…
GuilhE
  • 11,591
  • 16
  • 75
  • 116
6
votes
4 answers

Android: Evaluate EditText after the user finishes editing

What I want I have an EditText, where the user can enter a value, such as 10.40. Once the user is done editing I am formatting his input to a currency, for instance the above mentioned value would get formatted to $10.40 (in the case of Locale.US).…
AgentKnopf
  • 4,295
  • 7
  • 45
  • 81
6
votes
5 answers

Android Handling many EditText fields in a ListView

Just a basic question: If I have several dozen EditText fields that are part of a ListAdapter, how can the individual EditText fields know to which row they belong? Currently I am using TextWatcher to listen for text input. I have tried extending…
Rob
  • 762
  • 2
  • 21
  • 44
1 2
3
41 42