当我返回一个常规的int并尝试将该int用作Visibility-annotated int的输入参数时,Android工作室会抱怨。如何对我的方法进行注释,以便AS不会产生此警告?我看到View有一个公共@interface“可见性”,但由于一些奇怪的原因,即使它是公开的,我也无法从我的项目中引用<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<body>
<p contenteditable="true">This is a paragraph. It is editable. Try to change this text. On change of the content do call an ajax and update the db.</p>
</body>
</html>
。为什么呢?
我的方法:
android.view.View.Visibility
我需要什么:
public static int booleanToVisibleOrInvisible(boolean visible) {
return visible ? View.VISIBLE : View.INVISIBLE;
}
答案 0 :(得分:22)
但是出于一些奇怪的原因,我无法从我的项目中引用android.view.View.Visibility,即使它是公开的。
查看源代码,您会看到此注释已被注释&#39;使用@hide
标记:
/** @hide */
@IntDef({VISIBLE, INVISIBLE, GONE})
@Retention(RetentionPolicy.SOURCE)
public @interface Visibility {}
@hide
标记用于从android.jar
文件中排除带注释的包/类/方法/ etc,因此它在编译时不可用。我怀疑你可以在代码中以某种方式使用相同的注释,除非Google工程师从源代码中删除@hide
标记。
您可以使用//noinspection ResourceType
评论来取消此警告。