Class GridItem

GridItem

使用者在格狀小工具中互動的項目。

適用於 Google Workspace 外掛程式和 Google Chat 應用程式。

如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如 CardService.GridItemLayout.TEXT_BELOW

var gridItem = CardService.newGridItem()
    .setIdentifier("itemA")
    .setTitle("This is a cat")
    .setImage(CardService.newImageComponent())
    .setLayout(CardService.GridItemLayout.TEXT_BELOW);

方法

方法傳回類型簡短說明
setIdentifier(id)GridItem設定格線項目的 ID。
setImage(image)GridItem設定這個格線項目的圖片。
setLayout(layout)GridItem設定格線項目的文字和圖片版面配置。
setSubtitle(subtitle)GridItem設定格線項目的子標題。
setTextAlignment(alignment)GridItem設定格線項目的水平對齊方式。
setTitle(title)GridItem設定格線項目的標題文字。

內容詳盡的說明文件

setIdentifier(id)

設定格線項目的 ID。當使用者點選這個格線項目時,這個 ID 會在父項格線的 on_click 回呼參數中傳回。

參數

名稱類型說明
idStringID。

回攻員

GridItem:這個物件用於鏈結。


setImage(image)

設定這個格線項目的圖片。

參數

名稱類型說明
imageImageComponentImageComponent 物件。

回攻員

GridItem:這個物件用於鏈結。


setLayout(layout)

設定格線項目的文字和圖片版面配置。預設值為 TEXT_BELOW

參數

名稱類型說明
layoutGridItemLayout版面配置設定。

回攻員

GridItem:這個物件用於鏈結。


setSubtitle(subtitle)

設定格線項目的子標題。

參數

名稱類型說明
subtitleString字幕文字。

回攻員

GridItem:這個物件用於鏈結。


setTextAlignment(alignment)

設定格線項目的水平對齊方式。預設值為 START。

參數

名稱類型說明
alignmentHorizontalAlignment對齊設定。

回攻員

GridItem:這個物件用於鏈結。


setTitle(title)

設定格線項目的標題文字。

參數

名稱類型說明
titleString標題文字。

回攻員

GridItem:這個物件用於鏈結。