简体   繁体   English

Android常数存放在哪里?

[英]Where do Android constants live?

The documentation for LinearLayout gives the value for constants in the documentation. LinearLayout文档提供了文档中常量的值。 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 http://developer.android.com/reference/android/widget/LinearLayout.html#VERTICAL

In Java, constants are always (static) members of some class; 在Java中,常量始终是某个类的(静态)成员; in this case, android.widget.LinearLayout . 在这种情况下,为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. 要引用它,您需要在源文件顶部的类( import android.widget.LinearLayout;import android.widget.LinearLayout;后,在源代码中编写LinearLayout.VERTICAL 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. 或者,如果这是您唯一一次提到LinearLayout ,那么您可以编写android.widget.LinearLayout.VERTICAL而不进行任何导入,但这是不常见的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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