-2

Here the vector of what i'm trying to do

There Will be 2 tabs and one imageview or something between those two tabs, and the logo should be unclickable.

I've tried almost every approach but failed.

Anyone who knows how to do it?

Code :

        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tabs2);
        tabLayout.setupWithViewPager(mViewPager);
        tabLayout.getTabAt(1).setIcon(R.drawable.logo);



    }

    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {

            switch (position) {
                case 0:

                    return new LeaderBoard();

                case 1:

                    return new Logo();

                case 2:

                    return new Recent_Post();

                default:

                    return null;
            }

        }

        @Override
        public int getCount() {
            // Show 3 total pages.
            return 3;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "LeaderBoard";
                case 1:
                    return "";
                case 2:
                    return "Recent Posts";
            }
            return null;
        }
    }
Pranav Fulkari
  • 187
  • 2
  • 12
  • 1
    Show your code so we can see where you start? How far have you reached – Xenolion Oct 21 '17 at 14:25
  • I can't share the code because its too much lines but i can share the concept. I've added another tab and there are now 3 tabs, so the middle tab consists only logo not the text in title, but the problem is it creates another view which i don't want, that middle tab should not be clickable – Pranav Fulkari Oct 21 '17 at 14:36
  • 1
    You question is easy to do. So as I can answer by code. (Thats how we do in StackOverflow )otherwise it will be downvoted and deleted. You have to show how much you tried so that we can show you what to modify. Paste at least `tablayout` if you use that – Xenolion Oct 21 '17 at 14:39
  • See I've Added Code – Pranav Fulkari Oct 21 '17 at 15:21
  • Show some code on xml tablayout too. Show some `xml` of the tablayout. The one whose id is R.id.tabs2. I am sorry if I am disturbing. – Xenolion Oct 21 '17 at 15:41
  • http://www48.zippyshare.com/v/SmCzHCN5/file.html see this – Pranav Fulkari Oct 21 '17 at 16:11

1 Answers1

1

I've Solved my problem by switching the tabs between each other, Some Calculations.

int currentScreen = 0;

mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                if (position == 1) {
                    if(currentScreen == 0) {
                        mViewPager.setCurrentItem(2);
                        currentScreen = 2;
                    }else{
                        mViewPager.setCurrentItem(0);
                        currentScreen = 0;
                    }
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
Pranav Fulkari
  • 187
  • 2
  • 12