我有一个工作的PagerActivity(扩展FragmentActivity),里面有一堆Fragment对象。一切正常,但我现在要做的是在列表中显示片段的数量(假设有25个片段对象,我想在片段列表中显示当前数字)。
我该怎么做?我可以在Fragment对象中调用一些方法吗?
我正在填写PagerAdapter(摘录):
fragments = new Vector<Fragment>();
for (int i = 0; i < wiList.length; i++) {
WhiteboardImage tmpWi = wiList[i];
Bundle bundle = new Bundle();
bundle.putString("wiImage", gson.toJson(tmpWi));
bundle.putInt("positionInList", positionInList);
bundle.putInt("totalCount", wiList.length);
fragments.add(Fragment.instantiate(params[0], GalleryFragment.class.getName(), bundle));
}
mPagerAdapter = new GalleryPagerAdapter(getSupportFragmentManager(), fragments);
感谢您的帮助!
答案 0 :(得分:0)
我认为GalleryPagerAdapter
是FragmentViewPager
?那么片段的数量是fragments.size()
,没有?