CardService ช่วยให้คุณสร้างการ์ดทั่วไปที่ใช้ในผลิตภัณฑ์เสริมอื่นๆ ของ Google ได้ เช่น ส่วนเสริมของ Google Workspace
return CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle("CardTitle")) .build();
หรือจะส่งคืนการ์ดหลายแบบก็ได้ เช่น
return [ CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), CardService.newCardBuilder().build() ]
รายการต่อไปนี้แสดงวิธีที่คุณสามารถกําหนดการ์ดด้วยส่วนหัว ข้อความ รูปภาพ และรายการเมนู
function createWidgetDemoCard() { return CardService .newCardBuilder() .setHeader( CardService.newCardHeader() .setTitle('Widget demonstration') .setSubtitle('Check out these widgets') .setImageStyle(CardService.ImageStyle.SQUARE) .setImageUrl( 'https://www.example.com/images/headerImage.png')) .addSection( CardService.newCardSection() .setHeader('Simple widgets') // optional .addWidget(CardService.newTextParagraph().setText( 'These widgets are display-only. ' + 'A text paragraph can have multiple lines and ' + 'formatting.')) .addWidget(CardService.newImage().setImageUrl( 'https://www.example.com/images/mapsImage.png'))) .addCardAction(CardService.newCardAction().setText('Gmail').setOpenLink( CardService.newOpenLink().setUrl('https://mail.google.com/mail'))) .build(); }
พร็อพเพอร์ตี้
พร็อพเพอร์ตี้ | ประเภท | คำอธิบาย |
---|---|---|
BorderType | BorderType | การแจกแจง BorderType |
ComposedEmailType | ComposedEmailType | การแจกแจง ComposedEmailType |
ContentType | ContentType | การแจกแจง ContentType |
GridItemLayout | GridItemLayout | การแจกแจง GridItemLayout |
HorizontalAlignment | HorizontalAlignment | การแจกแจง HorizontalAlignment |
Icon | Icon | การแจกแจง Icon |
ImageCropType | ImageCropType | การแจกแจง ImageCropType |
ImageStyle | ImageStyle | การแจกแจง ImageStyle |
LoadIndicator | LoadIndicator | การแจกแจง LoadIndicator |
OnClose | OnClose | การแจกแจง OnClose |
OpenAs | OpenAs | การแจกแจง OpenAs |
SelectionInputType | SelectionInputType | การแจกแจง SelectionInputType |
TextButtonStyle | TextButtonStyle | การแจกแจง TextButtonStyle |
UpdateDraftBodyType | UpdateDraftBodyType | การแจกแจง UpdateDraftBodyType |
เมธอด
เอกสารประกอบโดยละเอียด
newActionResponseBuilder()
สร้าง ActionResponseBuilder
ใหม่
ไปกลับ
ActionResponseBuilder
— เครื่องมือสร้าง ActionResponse ว่างเปล่า
newAttachment()
newAuthorizationAction()
newAuthorizationException()
สร้าง AuthorizationException
ใหม่
ไปกลับ
AuthorizationException
— AuthorizationException ที่ว่างเปล่า
newBorderStyle()
newCalendarEventActionResponseBuilder()
สร้าง CalendarEventActionResponseBuilder
ใหม่
ไปกลับ
CalendarEventActionResponseBuilder
— CalendarEventActionResponseBuilder
ว่างเปล่า
newCardAction()
newCardBuilder()
newCardHeader()
newCardSection()
newComposeActionResponseBuilder()
สร้าง ComposeActionResponseBuilder
ใหม่
ไปกลับ
ComposeActionResponseBuilder
— เครื่องมือสร้าง ComposeActionResponse ว่างเปล่า
newDatePicker()
newDateTimePicker()
newDecoratedText()
newDivider()
สร้าง Divider
ใหม่ ตัวอย่างต่อไปนี้สร้างการ์ดแบบง่ายที่มี 2 ย่อหน้าโดยคั่นด้วยตัวแบ่ง
function buildCard() { let cardSection1TextParagraph1 = CardService.newTextParagraph() .setText('Hello world!'); let cardSection1Divider1 = CardService.newDivider(); let cardSection1TextParagraph2 = CardService.newTextParagraph() .setText('Hello world!'); let cardSection1 = CardService.newCardSection() .addWidget(cardSection1TextParagraph1) .addWidget(cardSection1Divider1) .addWidget(cardSection1TextParagraph2); let card = CardService.newCardBuilder() .addSection(cardSection1) .build(); return card; }
ไปกลับ
Divider
— ตัวแบ่ง
newDriveItemsSelectedActionResponseBuilder()
สร้าง DriveItemsSelectedActionResponseBuilder
ใหม่
ไปกลับ
DriveItemsSelectedActionResponseBuilder
— DriveItemsSelectedActionResponseBuilder
ว่างเปล่า
newEditorFileScopeActionResponseBuilder()
สร้าง EditorFileScopeActionResponseBuilder
ใหม่
ไปกลับ
EditorFileScopeActionResponseBuilder
— EditorFileScopeActionResponseBuilder
ว่างเปล่า
newImageButton()
newImageComponent()
newImageCropStyle()
newNotification()
newSelectionInput()
newSuggestions()
newSuggestionsResponseBuilder()
สร้าง SuggestionsResponseBuilder
ใหม่
ไปกลับ
SuggestionsResponseBuilder
— เครื่องมือสร้างคําแนะนําคําแนะนําที่ว่างเปล่า
newTextButton()
newTextParagraph()
newTimePicker()
newUniversalActionResponseBuilder()
สร้าง UniversalActionResponseBuilder
ใหม่
ไปกลับ
UniversalActionResponseBuilder
— เครื่องมือสร้าง UniversalActionResponse ที่ว่างเปล่า
newUpdateDraftActionResponseBuilder()
สร้าง UpdateDraftActionResponseBuilder
ใหม่
ไปกลับ
UpdateDraftActionResponseBuilder
— UpdateDraftsActionResponseBuilder ที่ว่างเปล่า
newUpdateDraftBccRecipientsAction()
สร้าง UpdateDraftBccRecipientsAction
ใหม่
ไปกลับ
UpdateDraftBccRecipientsAction
— อัปเดต UpdateDraftsBccRecipientAction ที่ว่างเปล่า
newUpdateDraftBodyAction()
newUpdateDraftCcRecipientsAction()
สร้าง UpdateDraftCcRecipientsAction
ใหม่
ไปกลับ
UpdateDraftCcRecipientsAction
— ไฟล์ร่างฉบับร่างว่างเปล่า
newUpdateDraftSubjectAction()
สร้าง UpdateDraftSubjectAction
ใหม่
ไปกลับ
UpdateDraftSubjectAction
— UpdateDraftsSubjectAction ว่างเปล่า
newUpdateDraftToRecipientsAction()
สร้าง UpdateDraftToRecipientsAction
ใหม่
ไปกลับ
UpdateDraftToRecipientsAction
— ไฟล์อัปเดตฉบับร่างแบบร่างสําหรับการดําเนินการที่ว่างเปล่า