[英]How to use IntDef annotation from another class
我正在嘗試使用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
注釋,從而阻止了我們直接在我們的應用中使用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.