Roku:如何在同一场景中添加MarkupGrid和Rowlist



我正在构建我的第一个roku应用变黑。

我决定将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>

homescene.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.}

因为您已经为rowlist创建了一个单独的组件(naty headerRowlist (,您需要在您的 homeScene.xml <<>/strong>:

<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>

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

相关内容

  • 没有找到相关文章

最新更新