弃用 Drawable.getOpacity()
Deprecation of Drawable.getOpacity()
我收到 Drawable.getOpacity() 的弃用警告。
...\progressbar\MaterialProgressDrawable.java:304: warning: [deprecation] getOpacity() in Drawable has been deprecated
public int getOpacity() {
^
1 warning
这个 class (MaterialProgressDrawable) 扩展了 Drawable 并实现了 Animatable。由于 getOpacity() 在父 class (@Deprecated public abstract @PixelFormat.Opacity int getOpacity();
) 中是抽象的,我也不能完全删除此方法。出路何在?
What is the way out?
好吧,由于 javadoc 暗示不再使用该方法,一种解决方案是按如下方式实现它:
@SuppressWarnings("deprecation")
public int getOpacity() {
throw new UnsupportedOperationException("getOpacity is deprecated");
}
我收到 Drawable.getOpacity() 的弃用警告。
...\progressbar\MaterialProgressDrawable.java:304: warning: [deprecation] getOpacity() in Drawable has been deprecated
public int getOpacity() {
^
1 warning
这个 class (MaterialProgressDrawable) 扩展了 Drawable 并实现了 Animatable。由于 getOpacity() 在父 class (@Deprecated public abstract @PixelFormat.Opacity int getOpacity();
) 中是抽象的,我也不能完全删除此方法。出路何在?
What is the way out?
好吧,由于 javadoc 暗示不再使用该方法,一种解决方案是按如下方式实现它:
@SuppressWarnings("deprecation")
public int getOpacity() {
throw new UnsupportedOperationException("getOpacity is deprecated");
}