Reputation: 511896
I'm creating an EditText
subclass and I want to make an Editable variable to pass to the super class.
When I originally tried
private Editable unicodeText = new Editable();
I got the error
'Editable' is abstract; cannot be instantiated
Searching for this error in Google did not return any helpful results, so now that I have found the answer I am adding this question with an answer below.
Upvotes: -1
Views: 1276
Reputation: 511896
Editable
is an interface, not a class, and as such cannot be instantiated.
Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces. (docs)
However, the class SpannableStringBuilder
implements Editable
so you can do the following:
private Editable unicodeText = new SpannableStringBuilder();
Thanks to this answer for setting me on the right track.
Upvotes: 1