- תחביר:
<property android:name="string" android:resource="resource specification" android:value="string" />
- בתוך:
<activity>
<activity-alias>
<application>
<provider>
<receiver>
<service>
- תיאור:
- צמד של שם-ערך לפריט של נתונים שרירותיים נוספים שניתן לספק למאפיין
רכיב הורה. רכיב רכיב יכול להכיל כל מספר של
<property>
אלמנטים משניים. שמות תקינים כוללים כל אחד מקבועי המאפיינים שמוגדרים ב הכיתהPackageManager
, הוגדרוPackageManager.Property
תגים במחלקות כמוWindowProperties
, וקבועים שרירותיים שהוגדרו אד הוק. משיגים ערכים בנפרד באמצעות אמצעי תשלום אחד (PackageManager.getProperty()
).מציינים ערכים רגילים באמצעות המאפיין
android:value
. צריך לציין מזהי משאבים עם התג מאפייןandroid:resource
. ציון גםandroid:value
וגםandroid:resource
לא חוקיים.לדוגמה, הקוד הבא מקצה כל ערך שמאוחסן במשאב
@string/kangaroo
ל השםzoo
:<property android:name="zoo" android:value=”@string/kangaroo” />
עם זאת, הקוד כאן מקצה את המזהה המספרי של המשאב, ולא את הערך המאוחסן במשאב,
zoo
:<property android:name="zoo" android:resource=”@string/kangaroo” />
- :
android:name
- שם הנכס. תוצאות של שגיאת ניתוח אם יש כמה תגים אחים של
<property>
כוללים את התג אותו שם. android:resource
- הפניה למשאב. מזהה המשאב הוא הערך שמוקצה לנכס. אפשר לאחזר את התעודה המזהה
מהנכס על ידי
PackageManager.Property.getResourceId()
android:value
- ערך שהוקצה לנכס. בטבלה הבאה מפורטים סוגי הנתונים החוקיים ושיטות הגישה של הערך הזה.
מאפיין:
סוג בעל הרשאת גישה ל-PackageManager.Property מחרוזת: צריך להשתמש לוכסנים הפוכים כפולים (\\) כדי לסמן תווים בתו בריחה (escape). לדוגמה, \\n
ו-\\uxxxxx
לתו UnicodegetString()
מספר שלם: לדוגמה, 100
getInteger()
ערך בוליאני: true
אוfalse
getBoolean()
צבע: בפורמט #rgb
,#argb
,#rrggbb
או#aarrggbb
getInteger()
מספר ממשי (float): לדוגמה, 1.23
getFloat()
הערה: תג
<property>
לא יכול להכיל גםandroid:value
וגםandroid:resource
מאפיינים. במקרה כזה, עדיף להשתמש ב-android:resource
.- הושקו ב:
- רמת API 31
<property>
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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"]]