1

我正在构建我的第一个 Roku 应用程序,虽然我能够分别渲染 MarkupGrid 和 Rowlist,但当我尝试在与 MarkupGrid 相同的场景上实现 Rowlist 时,我的屏幕变黑了。

我决定将 RowList 放在单独的组节点中,但我不确定如何使 RowList 再次在 HomeScene 中可见。

家庭场景.XML

<component name="HomeScene" extends="Scene"  initialFocus = "headerMarkupGrid">

    <script type="text/brightscript" uri="pkg:/components/HomeScene.brs" />

        <children>

        <Poster
                    id="logo" 
                    uri="pkg:/images/logo.png"
                    width="350"
                    height="150" />
   <MarkupGrid
            id="headerMarkupGrid"
            translation = "[ 275, 10 ]" 
            itemComponentName="TopNavGroup"
            itemSize="[550,150]"
            itemSpacing = "[ 0, 10 ]" 
            drawFocusFeedback = "false" 
            numRows="1"
            numColumns = "4" 
            />

        </children> 
</component>

家庭场景.brs

 sub init()
    home = m.top.findNode("HomeScene")
        ' grab content from my ContentNode
    MarkupGrid = m.top.findNode("headerMarkupGrid") 
    MarkupGrid.content = CreateObject("roSGNode","MarkupGridContent")

    rowList = m.top.findNode("rowList")
    m.top.setFocus(true)
end sub

headerRowList.XML

<?xml version="1.0" encoding="utf-8" ?> 

<component name="headerRowList" extends="Group"  initialFocus="RowList">

    <children>

       <RowList 
            id="RowList"
            itemSpacing = "[ 0, 10 ]"
            itemComponentName="PosterItem"
            itemSize="[1920,300]"
            numRows="3"
            rowItemSize="[[800,400],[400,300]]"
            rowHeights="[500,300]"
            rowItemSpacing="[[30,0],[120,0]]"
            focusXOffset="[300,30]"
            />
    </children>

</component>

headerRowList.brs

Function init()
    m.top.setFocus(true)

    m.RowList = m.top.findNode("RowList")

    content = CreateObject("roSGNode", "ContentNode")
    For i = 1 To 3
        rowContent = content.CreateChild("ContentNode")
        rowContent.TITLE = "Row " + i.ToStr()
        content.AppendChild(rowContent)
    Next
    m.RowList.observeField("content", "rowListContentChanged")
    m.RowList.content = content

    m.LoadTask = CreateObject("roSGNode", "RowListContentTaskVarWidth")
    m.LoadTask.content = content
    m.LoadTask.control = "RUN"

End Function

我希望场景看起来像这样:

[Nav option 1] [Nav option 2] [Nav option 3]
  ----------

{Rowlist that associates with "Nav Option 1" would go here.}
4

1 回答 1

1

由于您为 RowList 创建了一个单独的组件(名为headerRowList),因此您需要在HomeScene.xml中引用它:

<component name="HomeScene" extends="Scene"  initialFocus = "headerMarkupGrid">

    <script type="text/brightscript" uri="pkg:/components/HomeScene.brs" />

    <children>
        <Poster
            id="logo" 
            uri="pkg:/images/logo.png"
            width="350"
            height="150" />
        <MarkupGrid
            id="headerMarkupGrid"
            translation="[275,10]" 
            itemComponentName="TopNavGroup"
            itemSize="[550,150]"
            itemSpacing="[0,10]" 
            drawFocusFeedback="false" 
            numRows="1"
            numColumns="4" />
        <HeaderRowList id="rowList" />
    </children> 
</component>

这将使它在您的主场景中可见和可访问。

于 2019-05-26T23:27:02.510 回答