| <html devsite="true"> |
| <head> |
| <title>StringDef</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div itemscope="" itemtype="http://developers.google.com/ReferenceObject"> |
| <meta itemprop="name" content="StringDef"> |
| <meta itemprop="path" content="androidx.annotation"> |
| <meta itemprop="property" content="getOpen()"> |
| <meta itemprop="property" content="getValue()"> |
| <meta itemprop="language" content="JAVA"> |
| </div> |
| <div id="header-block"> |
| <div> |
| <h1>StringDef</h1> |
| </div> |
| <div id="metadata-info-block"> |
| <div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/annotation/StringDef.kt+class:androidx.annotation.StringDef&ss=androidx/platform/frameworks/support" class="external">View Source</a></div> |
| </div> |
| </div> |
| <div id="refdoc-switcher-placeholder"></div> |
| <p> |
| <pre>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-retention/index.html">Retention</a>(value = AnnotationRetention.SOURCE)<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-target/index.html">Target</a>(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS])<br>public annotation <a href="/reference/androidx/annotation/StringDef.html">StringDef</a></pre> |
| </p> |
| <hr> |
| <p>Denotes that the annotated String element, represents a logical type and that its value should be one of the explicitly named constants.</p> |
| <p>Example:</p> |
| <pre class="prettyprint">@Retention(SOURCE)<br>@StringDef({<br> POWER_SERVICE,<br> WINDOW_SERVICE,<br> LAYOUT_INFLATER_SERVICE<br>})<br>public @interface ServiceName {}<br>public static final String POWER_SERVICE = "power";<br>public static final String WINDOW_SERVICE = "window";<br>public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";<br>...<br>public abstract Object getSystemService(@ServiceName String name);</pre> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public constructors</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/StringDef.html#StringDef(kotlin.Array,kotlin.Boolean)">StringDef</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a> value, boolean open)</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>final boolean</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/StringDef.html#getOpen()">getOpen</a>()</code></div> |
| <p>Whether any other values are allowed.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> String[]</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/StringDef.html#getValue()">getValue</a>()</code></div> |
| <p>Defines the allowed constants for this element</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public constructors</h2> |
| <div class="api-item"><a name="StringDef(kotlin.Array, kotlin.Boolean)"></a><a name="StringDef-kotlin.Array-kotlin.Boolean-"></a><a name="stringdef"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="StringDef(kotlin.Array,kotlin.Boolean)">StringDef</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public <a href="/reference/androidx/annotation/StringDef.html#StringDef(kotlin.Array,kotlin.Boolean)">StringDef</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a> value, boolean open)</pre> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public methods</h2> |
| <div class="api-item"><a name="getOpen--"></a><a name="getopen"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="getOpen()">getOpen</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public final boolean <a href="/reference/androidx/annotation/StringDef.html#getOpen()">getOpen</a>()</pre> |
| <p>Whether any other values are allowed. Normally this is not the case, but this allows you to specify a set of expected constants, which helps code completion in the IDE and documentation generation and so on, but without flagging compilation warnings if other values are specified.</p> |
| </div> |
| <div class="api-item"><a name="getValue--"></a><a name="getvalue"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="getValue()">getValue</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> String[] <a href="/reference/androidx/annotation/StringDef.html#getValue()">getValue</a>()</pre> |
| <p>Defines the allowed constants for this element</p> |
| </div> |
| </div> |
| </body> |
| </html> |