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 回调参数中返回。
参数
返回
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):2026-04-13。
[null,null,["最后更新时间 (UTC):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"]]