I'm trying to create an Android tv application similar to the Youtube application. and I am using the Sofa library to do that. Now the problem comes when I am trying to show the headers for individual items in the RowsFragment
even when the RowsFragment
doesn't have a focus. following is the code for loading the dataset into browseFragment
private void loadRowsCustom() {
adapter = new ArrayObjectAdapter();
int split = 3;
int rowsFragmentCount = videoList.size() / split + (videoList.size() % split != 0 ? 1 : 0);
for (int i = 0; i < rowsFragmentCount; i++) {
ListRowPresenter lrp = new ListRowPresenter(FocusHighlight.ZOOM_FACTOR_LARGE);
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(lrp);
String category = "Category";
for (int j = 0; j < split && (i * split + j) < videoList.size(); j++) {
Video[] videos = videoList.get(i * split + j);
ArrayObjectAdapter rowCollAdapter = new ArrayObjectAdapter(new VideoPresenter());
rowCollAdapter.addAll(0, Arrays.asList(videos));
ListRow row = new ListRow(new HeaderItem(videos[0].category),rowCollAdapter);
rowsAdapter.add(row);
category = videos[0].category;
}
ArrayObjectAdapter fragmentAdapter = new ArrayObjectAdapter();
RowsSupportFragment rowsSupportFragment = new RowsSupportFragment();
rowsSupportFragment.setAdapter(rowsAdapter);
rowsSupportFragment.enableRowScaling(false);
fragmentAdapter.add(rowsSupportFragment);
adapter.add(new ListRow(new HeaderItem(category), fragmentAdapter));
}
browseSupportFragment.setAdapter(adapter);
browseSupportFragment.setHeadersState(BrowseSupportFragment.HEADERS_ENABLED);
browseSupportFragment.setOnSearchClickedListener(searchClickListener);
browseSupportFragment.setOnItemViewClickedListener(browseClickListener);
browseSupportFragment.setTitle("Google Videos");
}
The required and the current implementation is described as in the screenshots below:
true
is always passed to the superclass'setExpand
method. This should be marked as the correct answer. – Ceasar