2

NavigationTabBar View Pager with Tab. Github Link

I want to set Fragments in the viewpager but I'm not getting any far with what I'm doing might be because I'm naive in Android. Though I'm attaching code they used in exapmle application.Though I know ViwPager will handle the job. Can any one help me out where I have to call the Fragment and What code I should put in Fragment Class.

  final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
    viewPager.setAdapter(new PagerAdapter() {
        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public boolean isViewFromObject(View view, Object o) {

            return view.equals(o);
        }
        @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) {
            Log.d("Page ", Integer.toString(position));
            final View view = LayoutInflater.from(
                    getBaseContext()).inflate(R.layout.item_vp, null, false);
            final TextView txtPage = (TextView)view.findViewById(R.id.txt_vp_item_page);
            txtPage.setText(String.format("Page #%d", position));
            container.addView(view);
            return view;
        }
    });
AndroConsis
  • 51
  • 1
  • 6

0 Answers0