- نحو:
<property android:name="string" android:resource="resource specification" android:value="string" />
- موجود در:
-
<activity>
<activity-alias>
<application>
<provider>
<receiver>
<service>
- توضیحات:
- یک جفت نام-مقدار برای یک مورد از دادههای دلخواه اضافی که میتواند به مؤلفه والد ارائه شود. یک عنصر کامپوننت میتواند حاوی هر تعداد زیر عنصر
<property>
باشد. نامهای معتبر شامل هر یک از ثابتهای ویژگی تعریفشده در کلاسPackageManager
، تگهایPackageManager.Property
تعریفشده در کلاسهایی مانندWindowProperties
و ثابتهای دلخواه تعریفشده ad hoc هستند. با استفاده از متد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 Accessor رشته: برای فرار از کاراکترها از بک اسلش های دوتایی (\\) استفاده کنید. به عنوان مثال، \\n
و\\uxxxxx
برای یک کاراکتر یونیکدgetString()
عدد صحیح: برای مثال 100
getInteger()
بولی: یا true
یاfalse
getBoolean()
رنگ: به شکل #rgb
،#argb
،#rrggbb
یا#aarrggbb
getInteger()
Float: به عنوان مثال، 1.23
getFloat()
توجه: تگ
<property>
نباید دارای هر دو ویژگیandroid:value
وandroid:resource
باشد. اگر این اتفاق بیفتد،android:resource
ترجیح داده می شود.-
- معرفی شده در:
- API سطح 31
<مالکیت>
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],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"]]