在 Bixby 中,有什么方法可以按特定顺序在图像选择器中显示图像或按图像名称对其进行排序?
In Bixby, is there any way to display the images in image-picker in a particular order or sort it by image name?
我正在尝试向用户显示几张图片,以便他们 select 任何一张图片,并且我希望图片按特定顺序显示或根据其名称进行排序。但是每次 selection 屏幕加载图像似乎都是随机的。
我是这样传递图片的:
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)
}
}
}
我希望它们按给定的顺序显示或根据它们的名称排序(在本例中是相同的)。我该怎么办?
如果您在操作模型中列出值,则它没有任何顺序并且是随机的。
一个简单的解决方案是创建一个没有输入的单独操作,并在默认初始化中使用该操作。然后在linked JS函数中,return一个图片对象数组。显示顺序将是数组索引顺序。
更改default-init部分
default-init {
intent {
goal: GetDefaultImage
}
添加操作 GetDefaultImage
action(GetDefaultImage) {
type(Search)
output(Image)
}
链接的 JS 文件(link 它在您的端点文件中)
module.exports.function = function getDefaultImage () {
var result = []
// result should be in the format of result[0].url = 'imageUrl1'
// result[1].url = 'imageUrl2'
return result;
}
我正在尝试向用户显示几张图片,以便他们 select 任何一张图片,并且我希望图片按特定顺序显示或根据其名称进行排序。但是每次 selection 屏幕加载图像似乎都是随机的。
我是这样传递图片的:
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)
}
}
}
我希望它们按给定的顺序显示或根据它们的名称排序(在本例中是相同的)。我该怎么办?
如果您在操作模型中列出值,则它没有任何顺序并且是随机的。
一个简单的解决方案是创建一个没有输入的单独操作,并在默认初始化中使用该操作。然后在linked JS函数中,return一个图片对象数组。显示顺序将是数组索引顺序。
更改default-init部分
default-init {
intent {
goal: GetDefaultImage
}
添加操作 GetDefaultImage
action(GetDefaultImage) {
type(Search)
output(Image)
}
链接的 JS 文件(link 它在您的端点文件中)
module.exports.function = function getDefaultImage () {
var result = []
// result should be in the format of result[0].url = 'imageUrl1'
// result[1].url = 'imageUrl2'
return result;
}