คอมโพเนนต์รายการสถานที่ขั้นสูง
คอมโพเนนต์รายการสถานที่ขั้นสูงช่วยให้คุณกำหนดและแสดงรายการสถานที่ได้ คุณสามารถแสดงสถานที่ได้สูงสุด 20 แห่งจากชุดข้อมูลระบุตัวตนเดียวกันที่คอมโพเนนต์รายละเอียดสถานที่รองรับ (รหัสสถานที่ ชื่อทรัพยากรสถานที่ หรือพิกัดละติจูด/ลองจิจูด)
คุณสามารถเลือกแสดงรายการในแนวนอนหรือแนวตั้งก็ได้ การวางแนวเริ่มต้นคือแนวตั้ง ข้อมูลและตัวเลือกการกำหนดค่าเดียวกันกับที่แสดงในบัตรรายละเอียดสถานที่แบบ ย่อและแบบเต็ม จะพร้อมใช้งานสำหรับรายการแต่ละรายการ
ใช้อินเทอร์เฟซ PlaceActionProvider ของ AdvancedPlaceListFragment เพื่อสร้างรายการ
การเรียกเก็บเงิน
ระบบจะเรียกเก็บเงินคุณสำหรับการขอรายการแต่ละครั้ง และการเปลี่ยนแปลงรายการถือเป็นเหตุการณ์ที่เรียกเก็บเงินได้ใหม่
ตัวอย่าง
สร้าง Fragment AdvancedPlaceList
Kotlin
// Initialize first Places.initializeWithNewPlacesApiEnabled(context, API_KEY) // how fragment is created AdvancedPlaceListFragment.newInstance( selectedContent, orientation, R.style.BrandedPlaceDetailsTheme, ) // fragments support the same configurations that PlaceSearchFragment supports fragment.preferTruncation = false fragment.attributionPosition = AttributionPosition.BOTTOM fragment.mediaSize = AdvancedPlaceListFragment.MediaSize.SMALL fragment.selectable = true
แสดงรายการสถานที่
Kotlin
// You can use resourceNames or placeIds advancedPlaceListFragment.configureFromPlaceIds(placeIds) advancedPlaceListFragment.configureFromResourceNames(resourceNames) // Alternatively, use coordinates, which are a list of LatLng: advancedPlaceListFragment.configureFromCoordinates(coordinates) // Uses reverse geocoding to get the place
ฟังผลลัพธ์
Kotlin
// Attach the existing PlaceSearchFragmentListener to get notified when places load or are selected from the results list. override fun onAttachFragment(fragment: Fragment) { super.onAttachFragment(fragment) when (fragment) { // Reuse the placeSearchFragmetnListener from the Essentials version is AdvancedPlaceSearchFragment -> fragment.registerListener(placeSearchFragmentListener) // Use placeListFragmentListener, it's functionally identical but with a new name. is AdvancedPlaceListFragment -> fragment.registerListener(advancedPlaceListFragmentListener) } }