Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
matt604
Visitor

Populating GridScreen with setContentList from XML

I am using a combination of GridScreen and VideoScreen examples from the SDK. My goal is to make a GridScreen populated from XML which is hosted on my server. I am populating the List Names properly, but cannot figure out for the life of me how to populate the list of content in the rowIndex (setContentList function). Here are all the relevant code snippets I am using:

XML - EDIT: READ BELOW POST TO SEE SOLUTION!!!
(for now just using a very slightly modified sample feed XML from the SDK. Once I have this working I will make custom XML with my own content)

Relevant part of my appGridScreen.brs. Once again, I am getting the List Names, but cannot populate the contents.

Function showGridScreen(screen As Object, gridstyle as string) As string

print "enter showGridScreen"

conn = InitCategoryFeedConnection()

m.Categories = conn.LoadCategoryFeed(conn)
m.CategoryNames = conn.GetCategoryNames(m.Categories)

categoryList = conn.GetCategoryNames(m.Categories)

screen.setupLists(categoryList.count())
screen.SetListNames(categoryList)

initCategoryList()

for i = 0 to categoryList.count()-1
screen.SetContentList(i, getShowsForCategoryItem(m.CategoryNames))
end for
screen.Show()


The problem part is the last for loop. I am just not sure what the heck to pass to the getShowsForCategoryItem function, which currently looks like this:

Function getShowsForCategoryItem(category As Object) As Object

print "getting shows for category "; category

conn = InitShowFeedConnection(category.kids)
showList = conn.LoadShowFeed(conn)

return showList

End Function


So if you have a suggestion of how to populate the ListNames with the appropriate content, please let me know!
Thanks.
0 Kudos
2 REPLIES 2
matt604
Visitor

Re: Populating GridScreen with setContentList from XML

So this took me almost a day to figure out but I finally got it. Here's the solution just in case someone sees this thread in the future!

The issue was that I needed to remove categoryLeafs from the example videoplayer. There is quite a bit of code you have to change to do this properly, so I followed the step-by-step tutorial here:

viewtopic.php?f=34&t=57936

The for loop in showGridScreen ends up looking like this:

for i = 0 to categoryList.count()-1
m.curCategory = i
screen.SetContentList(i, getShowsForCategoryItem(m.Categories.kids[i]))
end for
screen.Show()

...


and here is getShowsForCategoryItem:

Function getShowsForCategoryItem(category As Object) As Object

print "getting shows for category "; category

conn = InitShowFeedConnection(category)
showList = conn.LoadShowFeed(conn)

return showList

End Function
0 Kudos
gobrowny
Visitor

Re: Populating GridScreen with setContentList from XML

hello Matt604,
Did this code actually work for you?. I am still fighting with it. Can you please post the entire mod. code. This may help us solving the puzzle. Thanks.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.