gpt4 book ai didi

android - 如何使用另一个类的 IntDef 注释

转载 作者:行者123 更新时间:2023-11-29 20:43:37 24 4
gpt4 key购买 nike

我正在尝试使用 android.content.pm.ActivityInfo 中的 @ScreenOrientation。它的声明:

@IntDef({
SCREEN_ORIENTATION_UNSPECIFIED,
SCREEN_ORIENTATION_LANDSCAPE,
...
})
@Retention(RetentionPolicy.SOURCE)
public @interface ScreenOrientation {}

如果我这样使用,编译器无法解析它:

public abstract class ActivityBase extends ActionBarActivity {

@ScreenOrientation
protected abstract int getPhoneOrientation();
}

import android.content.pm.ActivityInfo.*; 没有帮助。
@android.content.pm.ActivityInfo.ScreenOrientation 也没有帮助。

我在 gradle 文件中有注释库

compile 'com.android.support:support-annotations:22.0.0'

这是可能的还是注释只是以某种方式隐藏了?

最佳答案

注释确实是隐藏的 - 如果您查看 ActivityInfo(当前第 313 行): https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/content/pm/ActivityInfo.java

您会看到它上面有一个@hide 注释,从而防止我们直接在我们的应用程序中使用它。

关于android - 如何使用另一个类的 IntDef 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30664174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com