Android 可编辑是抽象的;不能实例化

Android Editable is abstract; cannot be instantiated

我正在创建一个 EditText 子class,我想创建一个可编辑变量以传递给超级 class。

我最初尝试的时候

private Editable unicodeText = new Editable();

我收到错误

'Editable' is abstract; cannot be instantiated

在 Google 中搜索此错误没有 return 任何有用的结果,所以现在我找到了答案,我将在下面添加这个问题和答案。

Editable 是一个接口,而不是 class,因此无法实例化。

Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces. (docs)

但是,class SpannableStringBuilder 实现了 Editable,因此您可以执行以下操作:

private Editable unicodeText = new SpannableStringBuilder();

感谢 this answer 让我走上正轨。