@Override
 public Object instantiateItem(View container, int position) {
   synchronized (viewsLock) {
     ViewPager pager = (ViewPager) container;
     TiViewProxy tiProxy = mViews.get(position);
     TiUIView tiView = tiProxy.getOrCreateView();
     View view = tiView.getOuterView();
     ViewGroup.LayoutParams params =
         new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
     TiCompositeLayout layout = new TiCompositeLayout(tiProxy.getActivity());
     ViewParent parent = view.getParent();
     if (parent instanceof ViewGroup) {
       pager.removeView((View) parent);
       ViewGroup group = (ViewGroup) parent;
       group.removeView(view);
     }
     layout.addView(view, tiView.getLayoutParams());
     if (position < pager.getChildCount()) {
       pager.addView(layout, position, params);
     } else {
       pager.addView(layout, params);
     }
     return tiProxy;
   }
 }
  /** 像view page中添加布局 */
  public void initpagedata() {
    if (viewPager.getChildCount() <= 0) {
      pagerAdapter = new MyPagerAdapter(views);
    }
    viewPager.setAdapter(pagerAdapter);
    viewPager.setOnPageChangeListener(
        new OnPageChangeListener() {
          @Override
          public void onPageSelected(int arg0) {

            btfav.setSelected(false);
            btnet.setSelected(false);
            btlocal.setSelected(false);
            switch (arg0) {
              case 0:
                btlocal.setSelected(true);
                break;
              case 1:
                btfav.setSelected(true);
                favoriteLayout.Refresh(FavoriteLayout.REFRESH_GROUP);
                break;
              case 2:
                btnet.setSelected(true);
                break;
            }
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });

    viewPager.setCurrentItem(0);
  }
Example #3
0
 @Override
 public void onPageScrollStateChanged(int position) {
   updateIndicator(subjectwisePager.getCurrentItem(), subjectwisePager.getChildCount());
 }
Example #4
0
 @Override
 public void onPageScrollStateChanged(int position) {
   Log.d("Jiffle", "current item" + position);
   updateIndicator(testwisePager.getCurrentItem(), testwisePager.getChildCount());
 }