动态列表中的行的Andr​​oid电视的Leanback添加更多的卡 [英] Dynamically add more cards in a list Row android TV leanback

查看:556
本文介绍了动态列表中的行的Andr​​oid电视的Leanback添加更多的卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在工作的一个Android TV的应用相当长的一段时间,我都来远在其上工作时。我试图发展像爆米花时间的应用程序,但它是谷歌nexus电视盒。
我在哪里卡住的问题是非常简单的,但即使很多的努力后,我仍然无法找出解决方案。
我从我的数据库中获取JSON数据里面有所有的电影细节和环节,这工作完全正常。
在所有应用视图

I am working on a Android TV app for quite some time now and I have come far while working on it. I am trying to develop an app like popcorn time but it's for Google nexus TV box. The problem where I am stuck in, is really simple but even after a lot of effort I am still unable to figure out the solution. I am fetching the json data from my database which has all the movies details and links and this works perfectly fine. Over all app view

现在那些谁使用的Andr​​oid电视上的你管的应用程序必须注意到,它是建立在Leanback的,当你在listrow向下滚动更多的卡加入到排,同样的应用程序所做的JSON调用来获取更多根据我们在滚动的类别数据。(这就是我想要做的)

Now those who have used the you tube app on Android TV must have noticed that it was built on leanback and as you scroll down in a listrow more cards are added into a row and likewise the app made the json calls to fetch more data according to the category we are scrolling in. (that's what I want to do)

现在它是不可能的,如果我要求大数据需要很长的时间,所以我设计了一个办法通过它我可以在滚动JSON调用获取一切从服务器,但我无法present它们在运行时listrow。

Right now it is impossible, if I request for large data it takes a long time to fetch everything from the server so I have devised a way via which I can make json calls on scroll but I am unable to present them in a listrow at runtime.

推荐答案

要项添加到presenter;

To add items to a presenter;

CardPresenter channelCardPresenter = new CardPresenter();
ArrayObjectAdapter channelRowAdapter = new ArrayObjectAdapter(channelCardPresenter);
channelRowAdapter.add(new Movie("Movie Title"));
HeaderItem header = new HeaderItem(0, "My Channels");
mRowsAdapter.add(new ListRow(header, channelRowAdapter));

当然,这可能只是你正在创建的UI第一次工作。未来的时间可能无法做到这一点。在我的应用程序,<一个href=\"https://github.com/Fleker/CumulusTV/blob/master/app/src/main/java/com/felkertech/n/tv/LeanbackFragment.java\" rel=\"nofollow\">https://github.com/Fleker/CumulusTV/blob/master/app/src/main/java/com/felkertech/n/tv/LeanbackFragment.java,我创建了一个将我想要做的应用程序的完全重绘每次调用方法:

Of course this may only work for the first time you're creating the UI. Future times may not do this. In my app, https://github.com/Fleker/CumulusTV/blob/master/app/src/main/java/com/felkertech/n/tv/LeanbackFragment.java, I create a method that will be called each time I want to do a full redraw of the app:

public void refreshUI() {
    prepareBackgroundManager();
    setupUIElements();
    loadRows(); //Generate and populate all the rows
    setupEventListeners();
}

这篇关于动态列表中的行的Andr​​oid电视的Leanback添加更多的卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆