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)
设置网格项的标识符。当用户点击此网格项时,父网格的 on_click 回调参数中会返回此 ID。
参数
返回
GridItem
- 此对象,用于链式调用。
setLayout(layout)
设置网格项的文本和图片的布局。默认值为 TEXT_BELOW
参数
返回
GridItem
- 此对象,用于链式调用。
setSubtitle(subtitle)
设置网格项的副标题。
参数
名称 | 类型 | 说明 |
subtitle | String | 副标题文本。 |
返回
GridItem
- 此对象,用于链式调用。
setTextAlignment(alignment)
设置网格项的水平对齐方式。默认值为 START。
参数
返回
GridItem
- 此对象,用于链式调用。
setTitle(title)
设置网格项的标题文本。
参数
返回
GridItem
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],["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"],null,[]]