我有一个具有CustomEditText(从AppCompatEditText扩展的)类的android库,出于某些安全原因,我不希望我的库用户访问在CustomEditText中键入的文本。我该如何实现?
您不能reduce the visibility of an inherited method,因此getText()将必须停留在public。
getText()
public
但是您可以重写它以不返回任何有意义的内容,并提供库类可以使用的受程序包保护的方法。