liaohuqiu / android-Ultra-Pull-To-Refresh

Ultra Pull to Refresh for Android. Support all the views.
MIT License
9.58k stars 2.65k forks source link

ViewPager嵌套在Fragment中TabPageIndicator不显示 #248

Open ChenShiChao opened 8 years ago

ChenShiChao commented 8 years ago

Demo中,如果把ViewPage嵌套在Fragment中,TabPageIndicator的name和指示都不显示;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.activity_view_pager, null);
    int startIndex = 0;

    mCatTabPageIndicator = (TabPageIndicator) view.findViewById(R.id.view_pager_tab_indicator);
    mFragmentViewPager = (ViewPager) view.findViewById(R.id.view_pager_view_pager);
    ArrayList<ViewPagerFragment> list = new ArrayList<ViewPagerFragment>();

    for (int i = 1; i <= 8; i++) {
        list.add(ViewPagerFragment.create(i));
    }
    mPagerAdapter = new FragmentViewPagerAdapter(getChildFragmentManager(), list);
    mFragmentViewPager.setAdapter(mPagerAdapter);

    mCatTabPageIndicator.setViewHolderCreator(new TabPageIndicator.ViewHolderCreator() {
        @Override
        public TabPageIndicator.ViewHolderBase createViewHolder() {
            return new HomeCatItemViewHolder();
        }
    });
    mCatTabPageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int i) {
            switchTo(i);
        }
    });
    mCatTabPageIndicator.setViewPager(mFragmentViewPager);

    mPtrFrame = (PtrClassicFrameLayout) view .findViewById(R.id.view_pager_ptr_frame);
    mPtrFrame.disableWhenHorizontalMove(true);
    mPtrFrame.setPtrHandler(new PtrHandler() {
        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return mPagerAdapter.checkCanDoRefresh();
        }

        @Override
        public void onRefreshBegin(PtrFrameLayout frame) {
            mPagerAdapter.updateData();
        }
    });
    mFragmentViewPager.setCurrentItem(startIndex);

    return view;
}
van048 commented 8 years ago

可以调试看看TabPageIndicator的updateTab方法,找找原因