Exemple #1
0
 private void initView() {
   mViewPager = new ViewPager(mContext);
   LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   mViewPager.setLayoutParams(params);
   mViewPager.setBackgroundColor(0xFF000000);
   setContentView(mViewPager);
   setParams();
   initViewPager();
 }
 public void start() {
   if (null == mDataLists || mDataLists.size() <= 0) {
     return;
   }
   mViewPager.setBackgroundColor(Color.TRANSPARENT);
   if (mAllowScroll) {
     handler.removeCallbacksAndMessages(null);
     handler.sendEmptyMessageDelayed(TAG_SCORLL, mContinuedTime * 1000);
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.photo_browser, container, false);
    adapter = new PhotoBrowserAdapter(getChildFragmentManager());

    viewPager = (ViewPager) rootView.findViewById(R.id.photo_browser_pager);
    viewPager.setAdapter(adapter);
    viewPager.setCurrentItem(startIndex);

    try {
      viewPager.setBackgroundColor(Color.parseColor(bgcolor));
    } catch (IllegalArgumentException e) {

    }

    viewPager.setOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            // enable/disable previous
            menuItemPrevious.setAvailable(position != 0);
            // Utils.setMenuItemAvailable(menuItemPrevious.me, position != 0);
            // enable/disable previous
            menuItemNext.setAvailable(position != (url.length - 1));
            // Utils.setMenuItemAvailable(menuItemNext, position != (nbPhoto - 1));
          }

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

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

    return rootView;
  }