Class CardService

บริการบัตร

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();
}

พร็อพเพอร์ตี้

พร็อพเพอร์ตี้ประเภทคำอธิบาย
BorderTypeBorderTypeการแจกแจง BorderType
ComposedEmailTypeComposedEmailTypeการแจกแจง ComposedEmailType
ContentTypeContentTypeการแจกแจง ContentType
GridItemLayoutGridItemLayoutการแจกแจง GridItemLayout
HorizontalAlignmentHorizontalAlignmentการแจกแจง HorizontalAlignment
IconIconการแจกแจง Icon
ImageCropTypeImageCropTypeการแจกแจง ImageCropType
ImageStyleImageStyleการแจกแจง ImageStyle
LoadIndicatorLoadIndicatorการแจกแจง LoadIndicator
OnCloseOnCloseการแจกแจง OnClose
OpenAsOpenAsการแจกแจง OpenAs
SelectionInputTypeSelectionInputTypeการแจกแจง SelectionInputType
TextButtonStyleTextButtonStyleการแจกแจง TextButtonStyle
UpdateDraftBodyTypeUpdateDraftBodyTypeการแจกแจง UpdateDraftBodyType

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
newAction()Actionสร้าง Action ใหม่
newActionResponseBuilder()ActionResponseBuilderสร้าง ActionResponseBuilder ใหม่
newAttachment()Attachmentสร้าง Attachment ใหม่
newAuthorizationAction()AuthorizationActionสร้าง AuthorizationAction ใหม่
newAuthorizationException()AuthorizationExceptionสร้าง AuthorizationException ใหม่
newBorderStyle()BorderStyleสร้าง BorderStyle ใหม่
newButtonSet()ButtonSetสร้าง ButtonSet ใหม่
newCalendarEventActionResponseBuilder()CalendarEventActionResponseBuilderสร้าง CalendarEventActionResponseBuilder ใหม่
newCardAction()CardActionสร้าง CardAction ใหม่
newCardBuilder()CardBuilderสร้าง CardBuilder ใหม่
newCardHeader()CardHeaderสร้าง CardHeader ใหม่
newCardSection()CardSectionสร้าง CardSection ใหม่
newComposeActionResponseBuilder()ComposeActionResponseBuilderสร้าง ComposeActionResponseBuilder ใหม่
newDatePicker()DatePickerสร้าง DatePicker ใหม่
newDateTimePicker()DateTimePickerสร้าง DateTimePicker ใหม่
newDecoratedText()DecoratedTextสร้าง DecoratedText ใหม่
newDivider()Dividerสร้าง Divider ใหม่
newDriveItemsSelectedActionResponseBuilder()DriveItemsSelectedActionResponseBuilderสร้าง DriveItemsSelectedActionResponseBuilder ใหม่
newEditorFileScopeActionResponseBuilder()EditorFileScopeActionResponseBuilderสร้าง EditorFileScopeActionResponseBuilder ใหม่
newFixedFooter()FixedFooterสร้าง FixedFooter ใหม่
newGrid()Gridสร้าง Grid ใหม่
newGridItem()GridItemสร้าง GridItem ใหม่
newIconImage()IconImageสร้าง IconImage ใหม่
newImage()Imageสร้าง Image ใหม่
newImageButton()ImageButtonสร้าง ImageButton ใหม่
newImageComponent()ImageComponentสร้าง ImageComponent ใหม่
newImageCropStyle()ImageCropStyleสร้าง ImageCropStyle ใหม่
newKeyValue()KeyValueสร้าง KeyValue ใหม่
newNavigation()Navigationสร้าง Navigation ใหม่
newNotification()Notificationสร้าง Notification ใหม่
newOpenLink()OpenLinkสร้าง OpenLink ใหม่
newSelectionInput()SelectionInputสร้าง SelectionInput ใหม่
newSuggestions()Suggestionsสร้าง Suggestions ใหม่
newSuggestionsResponseBuilder()SuggestionsResponseBuilderสร้าง SuggestionsResponseBuilder ใหม่
newSwitch()Switchสร้าง Switch ใหม่
newTextButton()TextButtonสร้าง TextButton ใหม่
newTextInput()TextInputสร้าง TextInput ใหม่
newTextParagraph()TextParagraphสร้าง TextParagraph ใหม่
newTimePicker()TimePickerสร้าง TimePicker ใหม่
newUniversalActionResponseBuilder()UniversalActionResponseBuilderสร้าง UniversalActionResponseBuilder ใหม่
newUpdateDraftActionResponseBuilder()UpdateDraftActionResponseBuilderสร้าง UpdateDraftActionResponseBuilder ใหม่
newUpdateDraftBccRecipientsAction()UpdateDraftBccRecipientsActionสร้าง UpdateDraftBccRecipientsAction ใหม่
newUpdateDraftBodyAction()UpdateDraftBodyActionสร้าง UpdateDraftBodyAction ใหม่
newUpdateDraftCcRecipientsAction()UpdateDraftCcRecipientsActionสร้าง UpdateDraftCcRecipientsAction ใหม่
newUpdateDraftSubjectAction()UpdateDraftSubjectActionสร้าง UpdateDraftSubjectAction ใหม่
newUpdateDraftToRecipientsAction()UpdateDraftToRecipientsActionสร้าง UpdateDraftToRecipientsAction ใหม่

เอกสารประกอบโดยละเอียด

newAction()

สร้าง Action ใหม่

ไปกลับ

Action — การดําเนินการว่างเปล่า


newActionResponseBuilder()

สร้าง ActionResponseBuilder ใหม่

ไปกลับ

ActionResponseBuilder — เครื่องมือสร้าง ActionResponse ว่างเปล่า


newAttachment()

สร้าง Attachment ใหม่

ไปกลับ

Attachment — ไฟล์แนบว่างเปล่า


newAuthorizationAction()

สร้าง AuthorizationAction ใหม่

ไปกลับ

AuthorizationAction — AuthorizationAction ว่างเปล่า


newAuthorizationException()

สร้าง AuthorizationException ใหม่

ไปกลับ

AuthorizationException — AuthorizationException ที่ว่างเปล่า


newBorderStyle()

สร้าง BorderStyle ใหม่

ไปกลับ

BorderStyle — รูปแบบเส้นขอบที่ว่างเปล่า


newButtonSet()

สร้าง ButtonSet ใหม่

ไปกลับ

ButtonSet — ชุดปุ่มที่ว่างเปล่า


newCalendarEventActionResponseBuilder()

สร้าง CalendarEventActionResponseBuilder ใหม่

ไปกลับ

CalendarEventActionResponseBuilderCalendarEventActionResponseBuilder ว่างเปล่า


newCardAction()

สร้าง CardAction ใหม่

ไปกลับ

CardAction — CardAction ที่ว่างเปล่า


newCardBuilder()

สร้าง CardBuilder ใหม่

ไปกลับ

CardBuilder — เครื่องมือสร้างการ์ดที่ว่างเปล่า


newCardHeader()

สร้าง CardHeader ใหม่

ไปกลับ

CardHeader — CardHeader ที่ว่างเปล่า


newCardSection()

สร้าง CardSection ใหม่

ไปกลับ

CardSection — CardSection ที่ว่างเปล่า


newComposeActionResponseBuilder()

สร้าง ComposeActionResponseBuilder ใหม่

ไปกลับ

ComposeActionResponseBuilder — เครื่องมือสร้าง ComposeActionResponse ว่างเปล่า


newDatePicker()

สร้าง DatePicker ใหม่

ไปกลับ

DatePicker — เครื่องมือเลือกวันที่ที่ว่างเปล่า


newDateTimePicker()

สร้าง DateTimePicker ใหม่

ไปกลับ

DateTimePicker — วันที่และเวลาว่างเปล่า


newDecoratedText()

สร้าง DecoratedText ใหม่

ไปกลับ

DecoratedText — ข้อความตกแต่งเปล่า


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 ใหม่

ไปกลับ

DriveItemsSelectedActionResponseBuilderDriveItemsSelectedActionResponseBuilder ว่างเปล่า


newEditorFileScopeActionResponseBuilder()

สร้าง EditorFileScopeActionResponseBuilder ใหม่

ไปกลับ

EditorFileScopeActionResponseBuilderEditorFileScopeActionResponseBuilder ว่างเปล่า


newFixedFooter()

สร้าง FixedFooter ใหม่

ไปกลับ

FixedFooter — SecureFooter ที่ว่างเปล่า


newGrid()

สร้าง Grid ใหม่

ไปกลับ

Grid — ตารางกริดว่างเปล่า


newGridItem()

สร้าง GridItem ใหม่

ไปกลับ

GridItem — รายการตารางกริดที่ว่างเปล่า


newIconImage()

สร้าง IconImage ใหม่

ไปกลับ

IconImage — รูปภาพไอคอนว่างเปล่า


newImage()

สร้าง Image ใหม่

ไปกลับ

Image — รูปภาพว่างเปล่า


newImageButton()

สร้าง ImageButton ใหม่

ไปกลับ

ImageButton — ปุ่มรูปภาพที่ว่างเปล่า


newImageComponent()

สร้าง ImageComponent ใหม่

ไปกลับ

ImageComponent — ImageComponent ที่ว่างเปล่า


newImageCropStyle()

สร้าง ImageCropStyle ใหม่

ไปกลับ

ImageCropStyle — รูปภาพว่างเปล่า


newKeyValue()

สร้าง KeyValue ใหม่

ไปกลับ

KeyValue — คีย์-ค่าที่ว่างเปล่า


newNavigation()

สร้าง Navigation ใหม่

ไปกลับ

Navigation — การนําทางที่ว่างเปล่า


newNotification()

สร้าง Notification ใหม่

ไปกลับ

Notification — การแจ้งเตือนว่างเปล่า


สร้าง OpenLink ใหม่

ไปกลับ

OpenLink — OpenLink ที่ว่างเปล่า


newSelectionInput()

สร้าง SelectionInput ใหม่

ไปกลับ

SelectionInput — InputInput ที่ว่างเปล่า


newSuggestions()

สร้าง Suggestions ใหม่

ไปกลับ

Suggestions — คําแนะนําที่ว่างเปล่า


newSuggestionsResponseBuilder()

สร้าง SuggestionsResponseBuilder ใหม่

ไปกลับ

SuggestionsResponseBuilder — เครื่องมือสร้างคําแนะนําคําแนะนําที่ว่างเปล่า


newSwitch()

สร้าง Switch ใหม่

ไปกลับ

Switch — สวิตช์ว่างเปล่า


newTextButton()

สร้าง TextButton ใหม่

ไปกลับ

TextButton — TextButton ที่ว่างเปล่า


newTextInput()

สร้าง TextInput ใหม่

ไปกลับ

TextInput — TextInput ที่ว่างเปล่า


newTextParagraph()

สร้าง TextParagraph ใหม่

ไปกลับ

TextParagraph — TextParagraph ที่ว่างเปล่า


newTimePicker()

สร้าง TimePicker ใหม่

ไปกลับ

TimePicker — เครื่องมือเลือกเวลาที่ว่างเปล่า


newUniversalActionResponseBuilder()

สร้าง UniversalActionResponseBuilder ใหม่

ไปกลับ

UniversalActionResponseBuilder — เครื่องมือสร้าง UniversalActionResponse ที่ว่างเปล่า


newUpdateDraftActionResponseBuilder()

สร้าง UpdateDraftActionResponseBuilder ใหม่

ไปกลับ

UpdateDraftActionResponseBuilder — UpdateDraftsActionResponseBuilder ที่ว่างเปล่า


newUpdateDraftBccRecipientsAction()

สร้าง UpdateDraftBccRecipientsAction ใหม่

ไปกลับ

UpdateDraftBccRecipientsAction — อัปเดต UpdateDraftsBccRecipientAction ที่ว่างเปล่า


newUpdateDraftBodyAction()

สร้าง UpdateDraftBodyAction ใหม่

ไปกลับ

UpdateDraftBodyAction — UpdateDraftsBodyAction ว่างเปล่า


newUpdateDraftCcRecipientsAction()

สร้าง UpdateDraftCcRecipientsAction ใหม่

ไปกลับ

UpdateDraftCcRecipientsAction — ไฟล์ร่างฉบับร่างว่างเปล่า


newUpdateDraftSubjectAction()

สร้าง UpdateDraftSubjectAction ใหม่

ไปกลับ

UpdateDraftSubjectAction — UpdateDraftsSubjectAction ว่างเปล่า


newUpdateDraftToRecipientsAction()

สร้าง UpdateDraftToRecipientsAction ใหม่

ไปกลับ

UpdateDraftToRecipientsAction — ไฟล์อัปเดตฉบับร่างแบบร่างสําหรับการดําเนินการที่ว่างเปล่า