- sintassi:
<property android:name="string" android:resource="resource specification" android:value="string" />
- contenuto in:
<activity>
<activity-alias>
<application>
<provider>
<receiver>
<service>
- description:
- Una coppia nome-valore per un elemento di dati arbitrari aggiuntivi che può essere fornito al
principale. Un elemento componente può contenere un numero illimitato di elementi secondari
<property>
. Nomi validi includere qualsiasi costante di proprietà definita il corsoPackageManager
,PackageManager.Property
tag definiti in classi comeWindowProperties
e costanti arbitrarie definite ad hoc. Ottenere i valori individualmente utilizzandoPackageManager.getProperty()
.Specifica i valori ordinari con l'attributo
android:value
. Specifica gli ID risorsa con Attributoandroid:resource
. Specificare entrambi i valoriandroid:value
eandroid:resource
non sono validi.Ad esempio, il seguente codice assegna qualsiasi valore archiviato nella risorsa
@string/kangaroo
a il nome dizoo
:<property android:name="zoo" android:value=”@string/kangaroo” />
Il codice qui, tuttavia, assegna l'ID numerico della risorsa, non il valore archiviato nella risorsa,
zoo
:<property android:name="zoo" android:resource=”@string/kangaroo” />
- attributi:
android:name
- Il nome della proprietà. Risultati di un errore di analisi se più tag
<property>
di pari livello hanno i valori con lo stesso nome. android:resource
- Un riferimento a una risorsa. L'ID della risorsa è il valore assegnato alla proprietà. L'ID può essere recuperato
dalla proprietà
PackageManager.Property.getResourceId()
. android:value
- Un valore assegnato alla proprietà. La tabella seguente elenca i tipi di dati e i metodi di accesso validi per il valore
attributo:
Tipo Funzione di accesso PackageManager.Property Stringa: utilizza doppie barre rovesciate (\\) come caratteri di escape per i caratteri; ad esempio \\n
e\\uxxxxx
per un carattere UnicodegetString()
Numero intero: ad esempio 100
getInteger()
Booleano: true
ofalse
getBoolean()
Colore: nel formato #rgb
,#argb
,#rrggbb
o#aarrggbb
getInteger()
Numero in virgola mobile: ad esempio 1.23
getFloat()
Nota: un tag
<property>
non deve contenere siaandroid:value
siaandroid:resource
. In questo caso, è preferibile usareandroid:resource
.- introdotto in:
- Livello API 31
<proprietà>
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-27 UTC."],[],[],null,["# <property\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cproperty android:name=\"string\"\n android:resource=\"resource specification\"\n android:value=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cactivity\u003e](/guide/topics/manifest/activity-element)\n\n [\u003cactivity-alias\u003e](/guide/topics/manifest/activity-alias-element)\n\n [\u003capplication\u003e](/guide/topics/manifest/application-element)\n\n [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n\n [\u003creceiver\u003e](/guide/topics/manifest/receiver-element)\n\n [\u003cservice\u003e](/guide/topics/manifest/service-element)\n\ndescription:\n: A name-value pair for an item of additional, arbitrary data that can be supplied to the\n parent component. A component element can contain any number of `\u003cproperty\u003e` subelements. Valid names\n include any of the [property constants](/reference/android/content/pm/PackageManager#constants_1) defined in\n the [PackageManager](/reference/android/content/pm/PackageManager) class,\n [PackageManager.Property](/reference/android/content/pm/PackageManager.Property) tags defined\n in classes such as [WindowProperties](/reference/kotlin/androidx/window/WindowProperties), and arbitrary constants defined ad hoc. Obtain values individually using the\n [PackageManager.getProperty()](/reference/android/content/pm/PackageManager#getProperty(java.lang.String,%20java.lang.String)) method.\n\n Specify ordinary values with the [android:value](/guide/topics/manifest/property-element#val)`\n ` attribute. Specify resource IDs with the\n [android:resource](/guide/topics/manifest/property-element#rsrc) attribute. Specifying\n both `android:value` and `android:resource` is invalid.\n\n\n For example, the following code assigns whatever value is stored in the `@string/kangaroo` resource to\n the `zoo` name:\n\n\n ```xml\n \u003cproperty android:name=\"zoo\" android:value=”@string/kangaroo” /\u003e\n ```\n\n\n The code here, however, assigns the numeric ID of the resource, not the value stored in the resource, to\n `zoo`:\n\n\n ```xml\n \u003cproperty android:name=\"zoo\" android:resource=”@string/kangaroo” /\u003e\n ```\n\nattributes:\n:\n\n `android:name`\n : The name of the property. A parsing error results if multiple, sibling `\u003cproperty\u003e` tags have the\n same name.\n\n `android:resource`\n : A reference to a resource. The ID of the resource is the value assigned to the property. The ID can be retrieved\n from the property by\n [PackageManager.Property.getResourceId()](/reference/android/content/pm/PackageManager.Property#getResourceId()).\n\n `android:value`\n : A value assigned to the property. The following table lists valid data types and accessor methods for the value\n attribute: \n\n\n | Type | PackageManager.Property accessor |\n |-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|\n | String: Use double backslashes (\\\\\\\\) to escape characters; for example, `\\\\n` and `\\\\uxxxxx` for a Unicode character | [getString()](/reference/android/content/pm/PackageManager.Property#getString()) |\n | Integer: For example, `100` | [getInteger()](/reference/android/content/pm/PackageManager.Property#getInteger()) |\n | Boolean: Either `true` or `false` | [getBoolean()](/reference/android/content/pm/PackageManager.Property#getBoolean()) |\n | Color: In the form `#rgb`, `#argb`, `#rrggbb`, or `#aarrggbb` | [getInteger()](/reference/android/content/pm/PackageManager.Property#getInteger()) |\n | Float: For example, `1.23` | [getFloat()](/reference/android/content/pm/PackageManager.Property#getFloat()) |\n\n\nintroduced in:\n: API Level 31"]]