简体   繁体   中英

Where do Android constants live?

The documentation for LinearLayout gives the value for constants in the documentation. Can these be brought in from an existing package/namespace or do they need to be defined at the class or application level?

http://developer.android.com/reference/android/widget/LinearLayout.html#VERTICAL

In Java, constants are always (static) members of some class; in this case, android.widget.LinearLayout . To refer to it, you would write LinearLayout.VERTICAL in your source code, after importing the class ( import android.widget.LinearLayout; ) at the top of the source file. Or, if that is the only time you ever mention LinearLayout , you could write android.widget.LinearLayout.VERTICAL without any import, but this is uncommon style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM