In book and Internet, for example here Android Handling many EditText fields in a ListView, TextWatcher is class, but on android devoloper it is interface http://developer.android.com/reference/android/text/TextWatcher.html. And Eclipse say, that it is interface. Who is right?)
Asked
Active
Viewed 443 times
0
-
I copied his code and Eclipse say it si wrong - The type TextWatcher cannot be the superclass of MyTextWatcher; a superclass must be a class – user1884872 Dec 29 '12 at 03:40
-
1Oh, you're talking about the answer, not the question. Anyways, I'd say that the answer was largely general because you do not extend an interface, you implement it. I'd reckon that they meant `class MyTextWatcher implements TextWatcher` – A--C Dec 29 '12 at 03:42
2 Answers
1
TextWatcher is an interface. In the example you've given, it's used as an interface, and the MyTextWatcher class implements the TextWatcher interface. If TextWatcher were a class, it would need to use extends.
Interface:
private class MyTextWatcher implements TextWatcher {
Class:
private class ThisWontWork extends TextWatcher {

323go
- 14,143
- 6
- 33
- 41
0
TextWatcher is interface...in android.text.TextWatcher
public interface TextWatcher implements NoCopySpan

Shubhamhackz
- 7,333
- 7
- 50
- 71