Open juanlabrador opened 8 years ago
When I change of fragment, always return position 0.
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { switch (position) { case 0: return mHistoryFragment; case 1: return mPostFragment; default: return null; } } @Override public int getCount() { return 2; } }); mViewPager.setPageMargin(8); // TODO Convert 'px' to 'dp' mViewPager.setPageMarginDrawable(R.color.accent); mTabsAction.setViewPager(mViewPager); mTabsAction.setTitles(getString(R.string.button_new_history), getString(R.string.button_new_post)); //mTabsAction.setTabIndex(0, true); mTabsAction.setStripColor(getResources().getColor(R.color.accent)); mTabsAction.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { validateButton(); switch (position) { case 0: TAB = HISTORY; validateDraft(Constants.HISTORY); break; case 1: TAB = POST; validateDraft(Constants.POST); break; } } @Override public void onPageScrollStateChanged(int state) { } }); mTabsAction.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() { @Override public void onStartTabSelected(String title, int index) { validateButton(); switch (index) { case 0: TAB = HISTORY; validateDraft(Constants.HISTORY); break; case 1: TAB = POST; validateDraft(Constants.POST); break; } } @Override public void onEndTabSelected(String title, int index) { } });
thanks
Hello. Thanks for issue.This is seems like imbossinillity.
I have encountered this problem.
hava a try,https://github.com/hackware1993/MagicIndicator
Any workaround for this?
When I change of fragment, always return position 0.
thanks