Forum Discussion

abushnaq's avatar
abushnaq
Reel Rookie
4 years ago

Stuck trying to dynamically update a RowList

Hi all,

I'm brand new to Roku development, trying to develop through a POC. I got to a point where I can statically present a one-row RowList with a picture and a couple of labels, but I'm completely stuck on how I would go about adding a new item to the row?

I would post code but none of my code has come even close to working so doesn't seem like there's much of a point. If there's a tutorial for this that I missed please let me know as well.

Thanks!

Ahmad

  • I got a tiny bit further - code below successfully creates a RowListItem but then any attempt to feed that item to the row list fails. RowListItem and RowListContent definitions come from one of the example apps but I'll include them further down as well.

     

    item1 = createObject("RoSGNode", "RowListItem")
    	  itemContent = createObject("RoSGNode", "ContentNode")
    	  
    	  itemContent.HDPosterUrl = "http://server-ip:8000/image.png" 
            itemContent.text = "50"
            itemContent.title = "Monday"
    	  
    	  item1.itemContent = itemContent
    	  
    	rowlist = m.top.findNode("exampleRowList")
          
    	content1 = CreateObject("roSGNode", "RowListContent")
    	content1.content = item1	  
          rowlist.content = content1

         

     <component name = "RowListItem" extends = "Group" >
     
      <interface > 
        <field id = "itemContent" type = "node" onChange = "showcontent"/>
        <field id = "focusPercent" type = "float" onChange = "showfocus"/> 
        <field id = "rowFocusPercent" type = "float" onChange = "showrowfocus"/>
      </interface>
     
      <script type = "text/brightscript" >
    
        <![CDATA[
        sub init()
          m.itemposter = m.top.findNode("itemPoster") 
          m.itemmask = m.top.findNode("itemMask")
          m.itemlabel = m.top.findNode("itemLabel")
          m.itemlabel2 = m.top.findNode("itemLabel2")
        end sub
        sub showcontent()
          itemcontent = m.top.itemContent
          m.itemposter.uri = itemcontent.HDPosterUrl
          m.itemlabel2.text = itemcontent.text
          m.itemlabel.text = itemcontent.title
        end sub
        sub showfocus()
          scale = 1 + (m.top.focusPercent * 0.08)
          m.itemposter.scale = [scale, scale]
        end sub
        sub showrowfocus()
          m.itemmask.opacity = 0.75 - (m.top.rowFocusPercent * 0.75)
          m.itemlabel.opacity = m.top.rowFocusPercent
        end sub
        ]]>
    
      </script>
    
      <children >
    
        <Poster 
          id = "itemPoster" 
          translation = "[ 10, 10 ]" 
          width = "150" 
          height = "150" 
          scaleRotateCenter = "[ 256.0, 144.0 ]" >
    
          <Rectangle 
            id = "itemMask" 
            color = "0x000000FF" 
            opacity = "1.0" 
            width = "150" 
            height = "150" 
            scaleRotateCenter = "[ 256.0, 144.0 ]"/>
    
        </Poster>
    
    
        <Label 
          id = "itemLabel2"
          font = "font:MediumBoldSystemFont" 
          translation = "[ 0, 200 ]" 
          color = "0x00800080"
          horizAlign = "center" 
          width = "150" 
          opacity = "1.0"/>
    
        <Label 
          id = "itemLabel"
          font = "font:MediumBoldSystemFont" 
          translation = "[ 0, 250 ]" 
          color = "0x00800080"
          horizAlign = "center" 
          width = "150" 
          opacity = "1.0"/>
      </children>
    </component>

    Row list content:

    <component name = "RowListContent" extends = "ContentNode" >
      <children >
        <ContentNode title = "Through the weekend" >
          <ContentNode 
            HDPosterUrl = "http://www.sdktestinglab.com/Tutorial/images/eotextchangepg.jpg" 
            text = "50"
            title = "Monday" />
          <ContentNode 
            HDPosterUrl = "http://www.sdktestinglab.com/Tutorial/images/eotextchangepg.jpg"
            text = "55" 
            title = "Tuesday" />
          <ContentNode 
            HDPosterUrl = "http://www.sdktestinglab.com/Tutorial/images/eotextchangepg.jpg"
            text = "85" 
            title = "Wednesday" />
          <ContentNode 
            HDPosterUrl = "http://www.sdktestinglab.com/Tutorial/images/eotextchangepg.jpg"
            text = "75" 
            title = "Thursday" />
          <ContentNode 
            HDPosterUrl = "http://www.sdktestinglab.com/Tutorial/images/eotextchangepg.jpg"
            text = "70" 
            title = "Friday" />
        </ContentNode>
      </children>
    </component>

     

    • cocotower's avatar
      cocotower
      Roku Guru

      Log in to your Roku shell to see the debugger output.  It should give some clue where the error is happening.

      I haven't gotten into dynamically updating a rowlist yet but I think I've tried once and gave up.  Correct me if I'm wrong but I thought you load it once and that's it, which I hate.  Post your new findings.