• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.text;
18 
19 /**
20  * When an object of this type is attached to an Editable, its methods will
21  * be called when the text is changed.
22  */
23 public interface TextWatcher extends NoCopySpan {
24     /**
25      * This method is called to notify you that, within <code>s</code>,
26      * the <code>count</code> characters beginning at <code>start</code>
27      * are about to be replaced by new text with length <code>after</code>.
28      * It is an error to attempt to make changes to <code>s</code> from
29      * this callback.
30      */
beforeTextChanged(CharSequence s, int start, int count, int after)31     public void beforeTextChanged(CharSequence s, int start,
32                                   int count, int after);
33     /**
34      * This method is called to notify you that, within <code>s</code>,
35      * the <code>count</code> characters beginning at <code>start</code>
36      * have just replaced old text that had length <code>before</code>.
37      * It is an error to attempt to make changes to <code>s</code> from
38      * this callback.
39      */
onTextChanged(CharSequence s, int start, int before, int count)40     public void onTextChanged(CharSequence s, int start, int before, int count);
41 
42     /**
43      * This method is called to notify you that, somewhere within
44      * <code>s</code>, the text has been changed.
45      * It is legitimate to make further changes to <code>s</code> from
46      * this callback, but be careful not to get yourself into an infinite
47      * loop, because any changes you make will cause this method to be
48      * called again recursively.
49      * (You are not told where the change took place because other
50      * afterTextChanged() methods may already have made other changes
51      * and invalidated the offsets.  But if you need to know here,
52      * you can use {@link Spannable#setSpan} in {@link #onTextChanged}
53      * to mark your place and then look up from here where the span
54      * ended up.
55      */
afterTextChanged(Editable s)56     public void afterTextChanged(Editable s);
57 }
58