<OnClick>
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ระบุการดำเนินการที่จะทำเมื่อผู้ใช้แตะมุมมอง อาจมี
<OnClick>
หลายโหนดสำหรับโหนดเดียว
<Transition>
โดยมี
แต่ละ <OnClick>
ระบุมุมมองเป้าหมายที่แตกต่างกัน และการดำเนินการที่ต่างกัน
จะทำงานเมื่อมีการแตะมุมมอง
วากยสัมพันธ์
<OnClick
motion:targetId="@id/target_view"
motion:clickAction="action"/>
แอตทริบิวต์
motion:targetId
- การดูที่กำลังได้รับการตรวจสอบ เมื่อผู้ใช้แตะที่มุมมองนี้ การเปลี่ยน
เกิดขึ้น
motion:ClickAction
- การดำเนินการที่จะทำเมื่อแตะมุมมอง ค่าที่รองรับได้แก่
ดังต่อไปนี้:
transitionToStart
- เคลื่อนไหวจากเลย์เอาต์ปัจจุบันไปยังเลย์เอาต์ที่ระบุโดย
ขององค์ประกอบ
<Transition>
motion::constraintSetStart
transitionToEnd
- เคลื่อนไหวจากเลย์เอาต์ปัจจุบันไปยังเลย์เอาต์ที่ระบุโดย
ขององค์ประกอบ
<Transition>
motion:constraintSetEnd
jumpToStart
- ข้ามจากเลย์เอาต์ปัจจุบันไปยังเลย์เอาต์ที่ระบุโดย
ขององค์ประกอบ
<Transition>
motion::constraintSetStart
jumpToEnd
- ข้ามจากเลย์เอาต์ปัจจุบันไปยังเลย์เอาต์ที่ระบุโดย
ขององค์ประกอบ
<Transition>
motion:constraintSetEnd
toggle
- หากเลย์เอาต์อยู่ในสถานะเริ่มต้น ให้เคลื่อนไหวไปจนถึงตอนท้าย หรือไม่เช่นนั้น
ภาพเคลื่อนไหวเริ่มต้น
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# <OnClick>\n\nSpecifies the action to perform when the user taps on a view. There can be\nmultiple `\u003cOnClick\u003e` nodes for a single\n[`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition), with\neach `\u003cOnClick\u003e` specifying a different target view and a different action to\nperform when the view is tapped.\n\nSyntax\n------\n\n```xml\n\u003cOnClick\n motion:targetId=\"@id/target_view\"\n motion:clickAction=\"action\"/\u003e\n```\n\nAttributes\n----------\n\n`motion:targetId`\n: View being monitored. When the user taps this view, the transition\n occurs.\n\n`motion:ClickAction`\n: Action to perform when the view is tapped. Supported values are the\n following:"]]