bixby - 在 Bixby 中,有没有办法以特定顺序在图像选择器中显示图像或按图像名称对其进行排序?
问题描述
我正在尝试向用户显示几张图像,让他们选择任何一张图像,并且我希望图像按特定顺序排列或根据其名称进行排序。但每次选择屏幕加载图像似乎都是随机的。
这就是我传递图像的方式:
default-init {
intent {
goal: Image
value: Image {
url: viv.core.Url("/images/img1.png")
}
value: Image {
url: viv.core.Url("/images/img2.png")
}
value: Image {
url: viv.core.Url("/images/img3.png")
}
value: Image {
url: viv.core.Url("/images/img4.png")
}
value: Image {
url: viv.core.Url("/images/img5.png")
}
value: Image {
url: viv.core.Url("/images/img6.png")
}
}
}
这是输入视图:
input-view {
match: Image (this) {
to-input: SelectImage
}
message {
template (Choose any image?)
}
render {
image-picker (this) {
size (Medium)
}
}
}
我希望它们以给定的顺序显示或根据它们的名称进行排序(在这种情况下是相同的)。我该怎么办?
解决方案
如果您在动作模型中列出值,则它没有任何顺序并且是随机的。
一个简单的解决方案是创建一个没有输入的单独操作,并在默认初始化中使用该操作。然后在链接的 JS 函数中,返回一个图像对象数组。显示顺序将是数组索引顺序。
更改默认初始化部分
default-init {
intent {
goal: GetDefaultImage
}
添加操作 GetDefaultImage
action(GetDefaultImage) {
type(Search)
output(Image)
}
链接的 JS 文件(将其链接到您的端点文件中)
module.exports.function = function getDefaultImage () {
var result = []
// result should be in the format of result[0].url = 'imageUrl1'
// result[1].url = 'imageUrl2'
return result;
}
推荐阅读
- python - 确定图像的颜色
- django - 从 Django 中的按钮调用函数
- r - Rmarkdown - 在括号之间插入注释
- python - 在视频上运行 TensorFlow 对象检测 API
- android - Volley 队列抛出 OutOfMemoryError “pthread_create
- c - 灵活数组成员上的结构
- schema.org - 用于产品捆绑包的 Schema.org
- html - 为什么这个 div 会低于页面的 50% 而不是直接到中心?
- spring-integration - 用于同步 REST 调用的 Spring Integration Outbound Gate 方式
- c# - C# 自动化:获取下拉值并存储禁用值