2016-09-24 16 views
-1
私は理解していない

は、私はWindowManager.javaのコードを見て、私は見ることができます:android java:なぜ私はいくつかのパブリックフィールドにアクセスでき、他にアクセスできないのですか?

public interface WindowManager extends ViewManager { 

    public static class LayoutParams extends ViewGroup.LayoutParams 
      implements Parcelable { 

     /** 
     * Control flags that are private to the platform. 
     * @hide 
     */ 
     public int privateFlags; 

     /** 
     * 
     * @see Gravity 
     */ 
     public int gravity; 

    } 
} 

なぜ私は、フィールドの重力にアクセスすることができますが、フィールドprivateFlagsにアクセスすることはできませんか?両方のフィールドの宣言が似ているように見えますが、どうしてできないのですか?

+0

私はここで外に出て、実際には「プライベートフラグ」にアクセスできると言っています。あなたを止めるのは何ですか? – Carcigenicate

+0

@GiantTree私が読んだところから、 '@ hide'はドキュメンテーションの生成を防ぐだけで、プログラマチックにフィールドにアクセスする能力には影響しません。 – Carcigenicate

+0

@GiantTreeああ、そうではないかもしれない。アクセス時にリンクのOPがエラーになっているように見えますが、ほとんどの場合、ドキュメント生成に影響すると答えています。 – Carcigenicate

答えて

0

フィールド「privateFlag」を呼び出しても、アクセスできないというわけではありません。 公開されているため、このフィールドにアクセスできます。

In java access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

  • At the top level—public, or package-private (no explicit modifier).
  • At the member level—public, private, protected, or package-private (no explicit modifier).

詳しくはhereをお読みください。以上の場合(アンドロイドで)@hide属性に関する何のため


it is just part of javadoc(droiddoc also), so the @hide just simply mean the method/class/field is excluded from the API docs.

herehere読みます。

+0

私はコンパイルしたときに、エラー:シンボルを見つけることができません:( – loki

関連する問題