عندما تريد أن يحمّل تطبيقك نتيجة بحث نصي أو نتيجة بحث بالقرب منك، استخدِم configureFromSearchByTextRequest() أو configureFromSearchNearbyRequest() مع الطلب.
Kotlin
fragment.configureFromSearchByTextRequest(searchByTextRequest)// or fragment.configureFromSearchNearbyRequest(searchNearbyRequest) for nearby search
Java
fragment.configureFromSearchByTextRequest(searchByTextRequest)// or fragment.configureFromSearchNearbyRequest(searchNearbyRequest) for nearby search
يمكنك أيضًا إضافة PlaceSearchFragmentListener اختياري إلى المكوّن لتلقّي عمليات ردّ الاتصال عند تحميل المكوّن أو اختيار مكان (إذا تم ضبطه على أن يكون قابلاً للاختيار) أو عند حدوث خطأ في تحميل المكوّن.
عند إنشاء مثيل لجزء، يمكنك تحديد مظهر يلغي أيًّا من سمات النمط التلقائي. القيمة التلقائية هي PlacesMaterialTheme. لمزيد من المعلومات حول تصميم المظاهر، راجِع مستندات "مكوّن تفاصيل المكان".
تستخدم أي سمات للمظهر لم يتم إلغاؤها الأنماط التلقائية. إذا أردت توفير مظهر داكن، يمكنك إضافة إدخال للون في values-night/colors.xml.
تاريخ التعديل الأخير: 2025-09-04 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-09-04 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Select platform: [Android](/maps/documentation/places/android-sdk/place-search-ui-kit \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/place-search-ui-kit \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/places-ui-kit/place-list \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nPlace Search component\n======================\n\n\nThe Place Search component of the Places UI Kit renders the results of a place search in a list.\n\n\nYou can customize the Place Search list. You can specify:\n\n- The content to display\n- Media size in vertical orientation\n- Text truncation\n- The orientation\n- Theme overrides that match your brand and app's design language\n- The position of the attribution\n- Whether a place is selectable\n\n\nYou can also customize the request to perform either a [`Search by text request`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/SearchByTextRequest) or a [`Search Nearby request`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/SearchNearbyRequest).\n\nBilling\n-------\n\n\nYou are billed each time the `configureFromSearchByTextRequest()` or `configureFromSearchNearbyRequest()` binding value is changed.\n\nAdd Place Search to your app\n----------------------------\n\n| **Tip:** [See the complete example](/maps/documentation/places/android-sdk/place-search-ui-kit#example).\n\n\nUse the Place Search widget by adding the [`PlaceSearchFragment`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment#newInstance(kotlin.collections.List,com.google.android.libraries.places.widget.model.Orientation,kotlin.Int)) [Fragment](https://developer.android.com/guide/fragments) to your layout.\n\n\nWhen you want your app to load a text search or nearby search result, call `configureFromSearchByTextRequest()` or `configureFromSearchNearbyRequest()` with the request. \n\n### Kotlin\n\n```kotlin\nfragment.configureFromSearchByTextRequest(searchByTextRequest)\n\n// or fragment.configureFromSearchNearbyRequest(searchNearbyRequest) for nearby search\n```\n\n### Java\n\n```java\nfragment.configureFromSearchByTextRequest(searchByTextRequest)\n\n// or fragment.configureFromSearchNearbyRequest(searchNearbyRequest) for nearby search\n \n```\n\n\nYou can also add an optional `PlaceSearchFragmentListener` to the component to receive callbacks when the component loads, a place is selected (if set to be selectable) or when there is an error loading the component. \n\n### Kotlin\n\n```kotlin\nfragment.registerListener(\n object : PlaceSearchFragmentListener {\n override fun onLoad(places: List\u003cPlace\u003e) {...}\n override fun onRequestError(e: Exception) {...}\n override fun onPlaceSelected(place: Place) {...}\n }\n)\n \n```\n\n### Java\n\n```java\nfragment.registerListener(\n new PlaceSearchFragmentListener() {\n @Override public void onLoad(List\u003c? extends Place\u003e places) {...}\n @Override public void onRequestError(Exception e) {...}\n @Override public void onPlaceSelected(Place place) {...}\n }\n)\n \n```\n\nCustomize the Place Search component\n------------------------------------\n\n### Customize content\n\nYou must specify which content your component will display. **Note:** The Place name will always appear.\n\n\nThis example configures the component to display the address and rating of the Place. \n\n### Kotlin\n\n```kotlin\nval fragment = PlaceSearchFragment.newInstance(listOf(Content.ADDRESS, Content.RATING))\n \n```\n\n### Java\n\n```java\nPlaceSearchFragment fragment = PlaceSearchFragment.newInstance(listOf(Content.ADDRESS,Content.RATING));\n \n```\n\n\nYou can also optionally customize the following aspects of the content that appears in your Place Search component:\n\n- [PlaceSearchFragment.Content](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment.Content): The content shown in the component.\n- [mediaSize](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/MediaSize): The photo size in the vertical orientation of the fragment. The default is `SMALL`.\n- [preferTruncation](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment#setPreferTruncation(boolean)): Whether to truncate text of each Place Details view.\n- [attributionPosition](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/AttributionPosition): Whether to show the Google Maps attribution at the top or bottom of the component.\n- [selectable](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment#getSelectable()): Whether each place in the list is selectable.\n\n\nAdd your customization configuration to [`PlaceSearchFragment`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment). \n\n### Kotlin\n\n```kotlin\nfragment.preferTruncation = false\nfragment.attributionPosition = AttributionPosition.BOTTOM\nfragment.mediaSize = MediaSize.SMALL\nfragment.selectable = true\n \n```\n\n### Java\n\n```java\nfragment.setPreferTruncation(false)\nfragment.setAttributionPosition(AttributionPosition.BOTTOM)\nfragment.setMediaSize(MediaSize.SMALL)\nfragment.setSelectable(true)\n \n```\n\n### Customize orientation\n\n\nThe default orientation is vertical. For horizontal orientation, specify [`Orientation.HORIZONTAL`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/Orientation) in [`PlaceSearchFragment.newInstance()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/PlaceSearchFragment#newInstance(kotlin.collections.List,com.google.android.libraries.places.widget.model.Orientation,kotlin.Int)). \n\n### Kotlin\n\n```kotlin\nPlaceSearchFragment.newInstance(\n PlaceSearchFragment.ALL_CONTENT,\n Orientation.HORIZONTAL\n)\n \n```\n\n### Java\n\n```java\nPlaceSearchFragment.newInstance(\n PlaceSearchFragment.ALL_CONTENT,\n Orientation.HORIZONTAL\n)\n \n```\n\n### Customize the theme\n\n\nWhen instantiating a fragment, you can specify a theme that overrides any of the default style attributes. The default is `PlacesMaterialTheme`. See the [Place Details Component documentation](/maps/documentation/places/android-sdk/place-details-ui-kit#customize-place-details) for more information on theming.\n\n\nAny theme attributes that are not overridden use the default styles. If you'd like to support a dark theme, you can add an entry for the color in `values-night/colors.xml`. \n\n```transact-sql\n \u003cstyle name=\"CustomizedTheme\" parent=\"PlacesMaterialTheme\"\u003e\n \u003citem name=\"placesColorPrimary\"\u003e@color/app_primary_color\u003c/item\u003e\n \u003citem name=\"placesColorOnSurface\"\u003e@color/app_color_on_surface\u003c/item\u003e\n \u003citem name=\"placesColorOnSurfaceVariant\"\u003e@color/app_color_on_surface\u003c/item\u003e\n \n \u003citem name=\"placesTextAppearanceBodySmall\"\u003e@style/app_text_appearence_small\u003c/item\u003e\n \n \u003citem name=\"placesCornerRadius\"\u003e20dp\u003c/item\u003e\n \u003c/style\u003e\n```\n\nExample\n-------\n\n### Kotlin\n\n```kotlin\nval fragment: PlaceSearchFragment =\nPlaceSearchFragment.newInstance(PlaceSearchFragment.STANDARD_CONTENT)\n\nfragment.preferTruncation = false\nfragment.attributionPosition = AttributionPosition.BOTTOM\nfragment.mediaSize = MediaSize.SMALL\nfragment.selectable = true\n\nfragment.registerListener(\n object : PlaceSearchFragmentListener {\n override fun onLoad(places: List\u003cPlace\u003e) {...}\n override fun onRequestError(e: Exception) {...}\n override fun onPlaceSelected(place: Place) {...}\n }\n)\n\nsupportFragmentManager\n .beginTransaction()\n .replace(R.id.fragment_container, fragment)\n .commitNow()\n\nfragment.configureFromSearchByTextRequest(searchByTextRequest)\n \n```\n\n### Java\n\n```java\nPlaceSearchFragment fragment = PlaceSearchFragment.newInstance(PlaceSearchFragment.STANDARD_CONTENT);\n\nfragment.setPreferTruncation(false)\nfragment.setAttributionPosition(AttributionPosition.BOTTOM)\nfragment.setMediaSize(MediaSize.SMALL)\nfragment.setSelectable(true)\n\nfragment.registerListener(\n new PlaceSearchFragmentListener() {\n @Override public void onLoad(List\u003c? extends Place\u003e places) {...}\n @Override public void onRequestError(Exception e) {...}\n @Override public void onPlaceSelected(Place place) {...}\n }\n)\n\ngetSupportFragmentManager()\n .beginTransaction()\n .replace(R.id.fragment_container, fragment)\n .commitNow();\n\nfragment.configureFromSearchByTextRequest(searchByTextRequest)\n \n```"]]