Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Class GridItem
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
GridItem
使用者在格線小工具中互動的項目。
適用於 Google Workspace 外掛程式和 Google Chat 應用程式。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
CardService.GridItemLayout.TEXT_BELOW。
const gridItem = CardService.newGridItem()
.setIdentifier('itemA')
.setTitle('This is a cat')
.setImage(CardService.newImageComponent())
.setLayout(CardService.GridItemLayout.TEXT_BELOW);
內容詳盡的說明文件
setIdentifier(id)
設定格線項目的 ID。使用者點選這個格狀項目時,系統會在父項格狀檢視的 on_click 回呼參數中傳回這個 ID。
參數
回攻員
GridItem - 這個物件,用於鏈結。
setImage(image)
設定這個格線項目的圖片。
參數
回攻員
GridItem - 這個物件,用於鏈結。
setLayout(layout)
設定格線項目的文字和圖片版面配置。預設值為 TEXT_BELOW
參數
回攻員
GridItem - 這個物件,用於鏈結。
setSubtitle(subtitle)
設定格狀項目的子標題。
參數
| 名稱 | 類型 | 說明 |
subtitle | String | 子標題文字。 |
回攻員
GridItem - 這個物件,用於鏈結。
setTextAlignment(alignment)
設定格線項目的水平對齊方式。預設值為 START。
參數
回攻員
GridItem - 這個物件,用於鏈結。
setTitle(title)
設定格線項目的標題文字。
參數
回攻員
GridItem - 這個物件,用於鏈結。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-04-13 (世界標準時間)。
[null,null,["上次更新時間:2026-04-13 (世界標準時間)。"],[],["Grid items, used in grid widgets for Google Workspace add-ons and Chat apps, are configured using methods like `setIdentifier`, `setImage`, `setLayout`, `setSubtitle`, `setTextAlignment`, and `setTitle`. These methods respectively assign an ID, an image, a text/image layout, a subtitle, text alignment, and a title. The `setIdentifier` method's ID is returned upon a user click. Default layout is `TEXT_BELOW` and the default alignment is `START`. Each method returns the `GridItem` object, enabling chaining.\n"]]