Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How goto to specific vertical ittem #7

Open
leoperezdev opened this issue Oct 26, 2016 · 2 comments
Open

How goto to specific vertical ittem #7

leoperezdev opened this issue Oct 26, 2016 · 2 comments

Comments

@leoperezdev
Copy link

Hello Julio is an interesting library. There is way to go to a certain position within the verticalPagers. For example I have a button that when pressed brings me to the last position of that verticalPager. It would like setCurrentItem method (int position) of ViewPager android. regards...

@waelhamda
Copy link

waelhamda commented Nov 13, 2016

First I want to say thank you very match to Julio Gomez for this excellent code , you saved my day Bro.

Dear leoperezdev , To solve this issue you have to change the method : InstantiateItem(final ViewGroup container ,int position) in DoubleViewPagerAdapter.java.

This is what I did and It's perfectly working :

@OverRide

public Object instantiateItem(final ViewGroup container, int position) {

    VerticalViewPager childVP = new VerticalViewPager(mContext);

    childVP.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    childVP.setAdapter(mAdapters.get(position));

    childVP.setOnPageChangeListener(new VerticalViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            ((MainActivity)mContext).changeVerticalView(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    container.addView(childVP);
    return childVP;
}

@dasheck0
Copy link

Hey @waelhamda Can you explain the code a little more? I don't quite get it unfortunately. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants