gpt4 book ai didi

android - 使用 ImageView 在 PageRow 元素之间导航

转载 作者:行者123 更新时间:2023-11-29 19:19:18 25 4
gpt4 key购买 nike

我想将图像添加到页眉元素。我关注了this教程并成功添加图像。它使用 ListRow 元素并与 ListRow 完美配合。

但是,当我用 PageRow 更改 ListRow 元素时,它不会在标题之间导航。以下是一些重要的变化。可能是什么原因?

IconHeaderItemPresenter.java

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object o) {
IconHeaderItem iconHeaderItem = (IconHeaderItem)((PageRow)o).getHeaderItem();
View rootView = viewHolder.view;
...
}

主要 fragment .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();
}

}
}

最佳答案

添加这两行

view.setFocusable(true);
view.setFocusableInTouchMode(true);

到你扩展的 RowHeaderPresenter 的 onCreateViewHolder

关于android - 使用 ImageView 在 PageRow 元素之间导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42759047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com