roku - Roku:更新 RowList 内容而不更改当前焦点项目
问题描述
有没有办法更新或附加项目到 RowList 内容,同时保持对当前选定/突出显示的行项目的关注?
rowList 中的每一行都是异步加载的独立列表。rowList 通过 observeField 方法更新(图 1)。问题是当新内容添加到行列表时,焦点会重置回第一行中的第一项。我想将注意力集中在用户导航到的任何行项目上,而其余行正在异步加载。
我认为问题可能是我每次都将 RowList.content 设置为一个新的更新 masterList(图 2)。
我更改了代码以附加一个新的行项目,它也导致焦点重置到第一行。
图 1.) m.ApiMixedListTask.observeField("responseObject", "onMixedListResponse") 图 2.) 函数 onMixedListResponse() masterList.push(newRowItems) m.top.gridContent = masterList 结束函数
图 3.) 行列表:https ://sdkdocs.roku.com/display/sdkdoc/RowList
<RowList
id="RowList"
focusBitmapUri="pkg:/images/focus_grid.9.png"
translation="[-60, 372]"
itemSize="[1327, 218]"
numRows="3"
itemSpacing="[13, 0]"
focusXOffset="[147]"
rowFocusAnimationStyle="fixedFocusWrap"
rowItemSize="[[262, 147]]"
rowItemSpacing="[[16.5, 3]]"
showRowLabel="true"
showRowCounter="true"
rowLabelOffset="[[147, 20]]"
/>
尽管这会导致糟糕的用户体验,但如果无法保持焦点,我可能只需要在内容加载时阻止用户交互。
解决方案
你需要知道 Roku 的一个奇怪的行为。如果您从函数中获取新行内容,即使您按原样创建,某些单元格也会无效。
例如,此代码将无法按预期工作:
function MapMatchList(data, countInARow = 4)
rowListContent = createObject("RoSGNode","ContentNode")
if data = invalid then return rowListContent
list = data.List
if list = invalid then return rowListContent
row = createObject("RoSGNode","ContentNode")
rowListContent.appendChild(row)
counter = 1
for i = 0 to list.count() - 1
if counter > countInARow
counter = 1
row = createObject("RoSGNode","ContentNode")
rowListContent.appendChild(row)
end if
match = MapMatch(list[i])
if match <> invalid
row.appendChild(match)
end if
counter = counter + 1
end for
return rowListContent
end Function
调用函数时,某些单元格变为无效
rows = MapMatchList(m.top.MoreData)
for i = 0 to rows.getChildCount() - 1
m.rowlist.content.appendChild(rows.getChild(i))
end for
您需要更改一些代码:
function MapMatchList(data, countInARow = 4, rowListContent = invalid)
if rowListContent = invalid then rowListContent = createObject("RoSGNode","ContentNode")
最后你可以调用它:
MapMatchList(m.top.MoreData, 4, m.rowlist.content)
推荐阅读
- php - 如何将以下小时转换为分钟?
- c# - SqlCommand.Cancel() 可以在 trasaction.commit 发生时处理回滚吗?
- java - Maven 发布:提交前准备 TAG
- azure - HTTPS 不适用于在具有自定义域的 Service Fabric 上运行的 Kestrel 3.2.187/ASPNET Core 2.1.5
- c# - 如何在 ASP.NET 中保存来自客户端删除请求的所有数据?
- regex - 如何使用 Powershell 从文件中递归地刮取电子邮件地址?
- java - Firebase 动态链接 java 客户端连接
- java - Amazon SQS 调用 lambda 函数
- javascript - 使用 Thymeleaf spring boot 提交后模式关闭
- sas - SAS 9.4 根据当前值替换当前行之后的所有值