Devlight / NavigationTabStrip

Navigation tab strip with smooth interaction.
Apache License 2.0
2.24k stars 313 forks source link

How can i catch the changing tab? #8

Closed canberkcakmak closed 8 years ago

canberkcakmak commented 8 years ago

Hi, i was looked the closed issues and saw Fragment implementing and i have a problem with this too. It's not clear to how to catch and how to change Fragments with your library. i have a 2 Fragments and i want to implement this with ViewPager but i can not. Please give an example for this. Thanks. By the way i 'm implementing your library with these codes:

`

       mViewPager.setAdapter(new PagerAdapter() {
        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public boolean isViewFromObject(final View view, final Object object) {
            return view.equals(object);
        }

        @Override
        public void destroyItem(final View container, final int position, final Object object) {
            ((ViewPager) container).removeView((View) object);
        }

        @Override
        public Object instantiateItem(final ViewGroup container, final int position) {
            final View view = new View(getBaseContext());
            container.addView(view);
            return view;
        }
    });

    mCenterNavigationTabStrip.setViewPager(mViewPager, 1);

`

GIGAMOLE commented 8 years ago

Hello. Thanks for question. Please, check the sample app in root folder of repo. Thanks.

canberkcakmak commented 8 years ago

I'm already checked sample app but i dont understand how can i do this. Please give some example basicly. Thanks

GIGAMOLE commented 8 years ago

Sample appa have some comment block. There are this two methods:

navigationTabStrip.setOnPageChangeListener(...); navigationTabStrip.setOnTabStripSelectedIndexListener(...);

You can set both of them, but reccomend to use one of them. If you need use ViewPager one use first method, if you need directly NTP use second.

Thanks.

canberkcakmak commented 8 years ago

I saw the comment block methods and i'm implementing this :

mCenterNavigationTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

But it's not still clear. I'm new on ViewPager's and where can i implement my fragments and how to connect with my 2 fragments and ViewPager. Thanks for answering.

GIGAMOLE commented 8 years ago

Try to find some tutorial in net.

canberkcakmak commented 8 years ago

I'm try. Asked stackoverflow but no one answered. Anyway good library, perfect ui but it's look like im going to delete this. Have a good day.