PageRow之間導航元素我要添加的圖像頭部的元件。我跟着this教程併成功添加圖片。它使用ListRow
元素,並與ListRow
完美配合。與圖像視圖
但是,當我改變ListRow
元素與PageRow
,它並沒有標題之間導航。以下是一些關鍵變化。可能是什麼原因?
IconHeaderItemPresenter.java
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object o) {
IconHeaderItem iconHeaderItem = (IconHeaderItem)((PageRow)o).getHeaderItem();
View rootView = viewHolder.view;
...
}
MainFragment.java
public void createRows(){
IconHeaderItem headerItem1 = new IconHeaderItem(1, getString(R.string.header_history), R.drawable.header_images);
PageRow pageRow1 = new PageRow(headerItem1);
mRowsAdapter.add(pageRow1);
IconHeaderItem headerItem2 = new IconHeaderItem(2, getString(R.string.header_recommendations), R.drawable.header_musics);
PageRow pageRow2 = new PageRow(headerItem2);
mRowsAdapter.add(pageRow2);
IconHeaderItem headerItem3 = new IconHeaderItem(3, getString(R.string.header_news), R.drawable.header_videos);
PageRow pageRow3 = new PageRow(headerItem3);
mRowsAdapter.add(pageRow3);
IconHeaderItem headerItem4 = new IconHeaderItem(4, getString(R.string.header_notifications), R.drawable.header_settings);
PageRow pageRow4 = new PageRow(headerItem4);
mRowsAdapter.add(pageRow4);
}
private static class PageRowFragmentFactory extends BrowseFragment.FragmentFactory {
private final BackgroundManager mBackgroundManager;
PageRowFragmentFactory(BackgroundManager backgroundManager) {
this.mBackgroundManager = backgroundManager;
}
@Override
public Fragment createFragment(Object rowObj) {
Row row = (Row)rowObj;
mBackgroundManager.setDrawable(null);
//id for news fragment
if (row.getHeaderItem().getId() == 3) {
return new SampleFragmentA();
} else {
return new SampleFragmentB();
}
}
}