예제 #1
2
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    ViewPager pager = (ViewPager) findViewById(R.id.parent);
    pager.setOffscreenPageLimit(1);
    pager.setAdapter(
        new FragmentPagerAdapter(getSupportFragmentManager()) {
          @Override
          public android.support.v4.app.Fragment getItem(int position) {
            return new ExampleFragment(String.valueOf(position));
          }

          @Override
          public int getCount() {
            return 5;
          }
        });
    LifeCycleRetriever.with(this)
        .addListener(
            new LifecycleListener() {
              @Override
              public void onLifeCycleStateChange(@LifeCycle.LifeCycleState int life, int level) {
                Log.e("tag", "ActivityLifeCycle,State:" + haha(life));
              }
            });
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.hard_fragment_clinic_list, container, false);
    mViewPager1 = (ViewPager) rootView.findViewById(R.id.hard_list_clinic_pager1);

    mViewPager2 = (ViewPager) rootView.findViewById(R.id.hard_list_clinic_pager2);
    mViewPager3 = (ViewPager) rootView.findViewById(R.id.hard_list_clinic_pager3);
    mViewPager4 = (ViewPager) rootView.findViewById(R.id.hard_list_clinic_pager4);

    mPagerAdapterDiet = new PagerAdapterDiet(getFragmentManager());
    mViewPager1.setAdapter(mPagerAdapterDiet);

    mPagerAdapterGyujung = new PagerAdapterGyujung(getFragmentManager());
    mViewPager2.setAdapter(mPagerAdapterGyujung);

    mPagerAdapterTheme1 = new PagerAdapterTheme1(getFragmentManager());
    mViewPager3.setAdapter(mPagerAdapterTheme1);

    mPagerAdapterTheme2 = new PagerAdapterTheme2(getFragmentManager());
    mViewPager4.setAdapter(mPagerAdapterTheme2);

    return rootView;
  }
예제 #3
0
  // -----------------------------------------------------------------------------
  // Removes the "view" at "position" from "views".
  // Retuns position of removed view.
  // The app should call this to remove pages; not used by ViewPager.
  public int removeView(ViewPager pager, int position) {
    // ViewPager doesn't have a delete method; the closest is to set the adapter
    // again.  When doing so, it deletes all its views.  Then we can delete the view
    // from from the adapter and finally set the adapter to the pager again.  Note
    // that we set the adapter to null before removing the view from "views" - that's
    // because while ViewPager deletes all its views, it will call destroyItem which
    // will in turn cause a null pointer ref.
    pager.setAdapter(null);
    views.remove(position);
    pager.setAdapter(this);

    return position;
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
   final ViewPager viewPager2 = (ViewPager) findViewById(R.id.viewPager2);
   viewPager.setAdapter(new MyPagerAdapter());
   viewPager2.setAdapter(new MyPagerAdapter());
   /** the current master viewPager */
   AtomicReference<ViewPager> masterRef = new AtomicReference<>();
   viewPager.addOnPageChangeListener(
       new ParallaxOnPageChangeListener(viewPager, viewPager2, masterRef));
   viewPager2.addOnPageChangeListener(
       new ParallaxOnPageChangeListener(viewPager2, viewPager, masterRef));
 }
예제 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    viewPager = (ViewPager) findViewById(R.id.vp_img);
    viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int i, float v, int i1) {}

          @Override
          public void onPageSelected(int i) {
            Toast.makeText(MainActivity.this, "" + i, Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onPageScrollStateChanged(int i) {}
        });
    viewPager.setAdapter(
        new PagerAdapter() {
          @Override
          public Object instantiateItem(ViewGroup container, int position) {
            SimpleDraweeView mDraweeViewe = new SimpleDraweeView(MainActivity.this);
            // ImageView imgView = (ImageView)
            // View.inflate(getApplicationContext(),R.layout.layout_imgview, null);
            /*GenericDraweeHierarchy hierarchy = mDraweeViewe.getHierarchy();
            hierarchy.setPlaceholderImage(imgIds[position]);*/

            mDraweeViewe.setScaleType(ImageView.ScaleType.CENTER_CROP);
            mDraweeViewe.setAspectRatio(1f);
            Uri imgUri = Uri.parse(imgUrls[position]);
            mDraweeViewe.setImageURI(imgUri);
            container.addView(mDraweeViewe);
            ivList.add(mDraweeViewe);
            return mDraweeViewe;
          }

          @Override
          public int getItemPosition(Object object) {
            return super.getItemPosition(object);
          }

          @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView(ivList.get(position));
          }

          @Override
          public int getCount() {
            return imgUrls.length;
          }

          @Override
          public boolean isViewFromObject(View view, Object object) {
            return view == object;
          }
        });
  }
  /** Adds tabs below the action bar. */
  private void addTabs() {
    viewPager = (ViewPager) findViewById(R.id.pager_main);
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // temp fix, to make sure that PATHAlerts isn't refreshing all the time
    viewPager.setOffscreenPageLimit(4);

    // Adding Tabs
    for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }

    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            // on changing the page
            // make respected tab selected
            actionBar.setSelectedNavigationItem(position);
          }

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

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });
  }
예제 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Back button
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Set title if object exists.
    MalwareObject malwareObject = getIntent().getExtras().getParcelable("malware");
    if (malwareObject != null) {
      getSupportActionBar().setTitle(malwareObject.getName());
    }
  }
예제 #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.default_layout);

    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

    final ScrollableTabView tabs = (ScrollableTabView) findViewById(R.id.scrollTabs);
    tabs.setViewPager(pager);
    tabs.setTabAdapter(new CustomTabAdapter(R.layout.my_tab_custom_text));

    findViewById(R.id.button_divider_color)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Random random = new Random();
                int dividerColor =
                    Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255));
                tabs.setDividerColor(dividerColor);
              }
            });

    findViewById(R.id.button_divider_visibility)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                tabs.setShowDivider(!tabs.isShowingSeparator());
              }
            });
  }
예제 #9
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // initialize the inflater
    mInflater = inflater;

    View rootView = mInflater.inflate(R.layout.app_ops_summary, container, false);
    mContentContainer = container;
    mRootView = rootView;

    mPageNames = getResources().getTextArray(R.array.app_ops_categories);

    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager());
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(adapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
      tabs.setTabIndicatorColorResource(android.R.color.holo_blue_light);
    } else {
      final TypedValue val = new TypedValue();
      getActivity().getTheme().resolveAttribute(android.R.attr.colorAccent, val, true);
      tabs.setTabIndicatorColor(val.data);
    }

    // We have to do this now because PreferenceFrameLayout looks at it
    // only when the view is added.
    if (container != null
        && "android.preference.PreferenceFrameLayout".equals(container.getClass().getName())) {
      new ObjectWrapper(rootView.getLayoutParams()).set("removeBorders", true);
    }

    return rootView;
  }
  private void initAssessments() {
    // TODO Auto-generated method stub
    prefsHandler = new PrefsHandler(AssessmentType.this);

    vpAssessments =
        (ViewPager)
            activityContentView.findViewById(R.id.assessments_view_viewPager_assessment_types);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    getActionBar().addTab(getActionBar().newTab().setText("Assignments").setTabListener(this));
    getActionBar().addTab(getActionBar().newTab().setText("C.A.T's").setTabListener(this));
    getActionBar().addTab(getActionBar().newTab().setText("End of Sem").setTabListener(this));

    vpAssessments.setAdapter(new AssessmentsPagerAdapter(getSupportFragmentManager()));
    vpAssessments.setOnPageChangeListener(this);

    if (prefsHandler.isSeasonEnabled()) {
      switch (prefsHandler.getSeason()) {
        case 4:
          vpAssessments.setCurrentItem(0);
          break;
        case 5:
          vpAssessments.setCurrentItem(1);
          break;
        case 6:
          vpAssessments.setCurrentItem(2);
          break;
        default:
          vpAssessments.setCurrentItem(0);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    Intent get_weight = getIntent();

    Bundle extras = get_weight.getExtras();
    if (extras != null) {
      weight_input = extras.getString("weight").toString();

      //            System.out.println(weight_input);

    }
  }
예제 #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    //        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    //        fab.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View view) {
    //                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
    //                        .setAction("Action", null).show();
    //            }
    //        });

  }
예제 #13
0
 private void setupViewPager(ViewPager viewPager) {
   ViewPageAdapter adapter = new ViewPageAdapter(getSupportFragmentManager());
   adapter.addFrag(new MaterialDesignFrag(getResources().getColor(R.color.colorAccent)), "CAT");
   adapter.addFrag(new GridViewFrag(), "DOG");
   adapter.addFrag(new RecyclerViewFrag(), "People");
   viewPager.setAdapter(adapter);
 }
예제 #14
0
  private void init() {
    mSwipeBackLayout.addSwipeListener(this);
    mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);

    PageAdapter adapter = new PageAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(adapter);

    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            Log.d(TAG, "position->" + position);
            if (position == 0) {
              getSwipeBackLayout().setEdgeSize(Utils.dp2px(200));
            } else {
              getSwipeBackLayout().setEdgeSize(0);
            }
          }

          @Override
          public void onPageSelected(int position) {}

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
    //        mViewPager.setPageTransformer(false, new PageTransformer());
  }
예제 #15
0
  protected void init() {
    // 存放头部导航的tv 文本控件
    tvList = new ArrayList<TextView>();
    // 存放头部导航中的 line控件
    rbList = new ArrayList<RadioButton>();
    TextView leftTV = (TextView) fa.findViewById(R.id.nearby_top_nav_left_tv);
    TextView middleTV = (TextView) fa.findViewById(R.id.nearby_top_nav_middle_tv);
    TextView rightTV = (TextView) fa.findViewById(R.id.nearby_top_nav_right_tv);
    RadioButton leftLine = (RadioButton) fa.findViewById(R.id.nearby_top_nav_left_line);
    RadioButton middleLine = (RadioButton) fa.findViewById(R.id.nearby_top_nav_middle_line);
    RadioButton rightLine = (RadioButton) fa.findViewById(R.id.nearby_top_nav_right_line);
    tvList.add(leftTV);
    tvList.add(middleTV);
    tvList.add(rightTV);
    rbList.add(leftLine);
    rbList.add(middleLine);
    rbList.add(rightLine);
    leftTV.setOnClickListener(this);
    middleTV.setOnClickListener(this);
    rightTV.setOnClickListener(this);
    leftTV.setText(R.string.team);
    middleTV.setText(R.string.player);
    rightTV.setText(R.string.park);

    // 初始进入的
    ((MainActivity) fa).changeNavText(tvList, 0);

    // 初始化球队,球友,球场三个面板
    ArrayList<Fragment> list = new ArrayList<Fragment>();
    list.add(new NearbyTeamFragment());
    list.add(new NearbyPlayerFragment());
    list.add(new NearbyParkFragment());
    NearbyFragmentAdapter adapter = new NearbyFragmentAdapter(fm, list);
    mvp.setAdapter(adapter);
  }
  private void initView() {
    mViewPager = (ViewPager) this.findViewById(R.id.viewpager);
    mPageNum = (TextView) this.findViewById(R.id.page_num);
    mEditText = (EditText) this.findViewById(R.id.edit_text);
    mButton = (Button) this.findViewById(R.id.button);
    mButton.setOnClickListener(this);

    List<Fragment> fragments = new ArrayList<Fragment>();
    Fragment fragment1 = MyOneFragment.newInstance();
    Fragment fragment2 = MyTwoFragment.newInstance();
    Fragment fragment3 = MyThreeFragment.newInstance();
    Fragment fragment4 = MyFourFragment.newInstance();
    Fragment fragment5 = MyFiveFragment.newInstance();

    fragments.add(fragment1);
    fragments.add(fragment2);
    fragments.add(fragment3);
    fragments.add(fragment4);
    fragments.add(fragment5);

    mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments);
    mViewPager.setAdapter(mMyFragmentPagerAdapter);
    mViewPager.setPageTransformer(true, new FragmentTransformer()); // 设置页面变换监听,对每个页面的变化都有一个变换的监听
    mViewPager.addOnPageChangeListener(new OnMyPageChangeListener()); // 页面变化监听
    mViewPager.setOffscreenPageLimit(2); // 设置缓存页面数。当前页,左右两边(单边)最大缓存页面数。
    //        mViewPager.setOnScrollChangeListener(new
    // OnMyScrollChangeListener());//滚动状态监听,minSdkVersion:23
    //        mViewPager.getCurrentItem();//获取当前显示页索引
    //        mViewPager.getOffscreenPageLimit();//获取缓存页面数
    //        mViewPager.onSaveInstanceState();
    //        mViewPager.setPageTransformer();
    setPageNum(0); // 设置显示首页
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_underline_page_indicator);
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setAdapter(
        new FragmentStatePagerAdapter(getSupportFragmentManager()) {
          @Override
          public int getCount() {
            return 5;
          }

          @Override
          public Fragment getItem(int position) {
            Fragment f = new SampleFragment();
            Bundle args = new Bundle();
            args.putInt(SampleFragment.PAGE_NUMBER, position + 1);
            f.setArguments(args);
            return f;
          }

          @Override
          public CharSequence getPageTitle(int position) {
            return "Page" + (position + 1);
          }
        });
    PageIndicator titleIndicator = (PageIndicator) findViewById(R.id.indicator);
    titleIndicator.setViewPager(viewPager);
  }
예제 #18
0
  /** Called when activity is created. */
  @SuppressLint("InlinedApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    LanguageUtils.setLanguageConfiguration(getResources());
    super.onCreate(savedInstanceState);

    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.help_view);
    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    FragmentPagerAdapter pageAdapter = getPageAdapter();
    mViewPager.setAdapter(pageAdapter);

    mIndicator = (UnderlinePageIndicator) findViewById(R.id.underline_indicator);
    mIndicator.setViewPager(mViewPager);
    mIndicator.setFades(false);

    mCloseButton = (ImageButton) findViewById(R.id.closeButton);
    mCloseButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
  }
 /** 图片循环 */
 private void initViewPager() {
   ViewGroup.LayoutParams mViewPagerlayoutParams = mViewPager.getLayoutParams();
   if (mViewPagerlayoutParams != null) {
     mViewPagerlayoutParams.width = Misc.getScreenDisplay(this)[0];
     mViewPagerlayoutParams.height = (int) (mViewPagerlayoutParams.width);
     mViewPager.setLayoutParams(mViewPagerlayoutParams);
   }
   mViewPager.setAdapter(new ProductDetailPicAdapter2(this, product.getImgList()));
   mViewPager.setOnPageChangeListener(this);
   // 设置布局参数
   LinearLayout.LayoutParams params =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int marginParam = Misc.dip2px(this, 10) / 2;
   llytPagerPoiner.removeAllViewsInLayout();
   for (int i = 0; i < product.getImgList().size(); i++) {
     // 设置按钮属性
     View item = new ImageView(this);
     item.setBackgroundResource(R.drawable.recommend_gallery);
     item.setTag(String.valueOf(i));
     // item.setOnClickListener(parentActivity);
     params.setMargins(marginParam, 0, marginParam, 0);
     params.weight = 1;
     llytPagerPoiner.addView(item, params);
   }
   llytPagerPoiner.getChildAt(0).setBackgroundResource(R.drawable.recommend_gallery_select);
 }
예제 #20
0
  private void initViewPages() {
    // 初始化四个布局
    Fragment01 tab01 = new Fragment01();
    Fragment02 tab02 = new Fragment02();
    Fragment03 tab03 = new Fragment03();
    Fragment04 tab04 = new Fragment04();
    mFragments.add(tab01);
    mFragments.add(tab02);
    mFragments.add(tab03);
    mFragments.add(tab04);
    // 初始化Adapter这里使用FragmentPagerAdapter
    mAdpter =
        new FragmentPagerAdapter(getSupportFragmentManager()) {
          @Override
          public Fragment getItem(int position) {

            return mFragments.get(position);
          }

          @Override
          public int getCount() {
            return mFragments.size();
          }
        };
    mViewPager.setAdapter(mAdpter);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);
    final View view = inflater.inflate(R.layout.fragment_books_pager, container, false);
    final Bundle extras = getArguments();

    if (extras != null) {
      mBookPosition = extras.getInt(Keys.BOOK_POSITION);
    }

    mBookDetailPager = (ViewPager) view.findViewById(R.id.pager_books);
    mBookDetailPager.setOnPageChangeListener(this);
    mSlidingLayout = (SlidingUpPanelLayout) view.findViewById(R.id.sliding_layout);
    mSlidingLayout.setPanelSlideListener(this);

    mAdapter = new BookPageAdapter(getChildFragmentManager(), null);
    mBookDetailPager.setAdapter(mAdapter);

    if (savedInstanceState == null) {
      final ProfileFragment fragment = new ProfileFragment();

      getChildFragmentManager()
          .beginTransaction()
          .replace(R.id.content_user_profile, fragment, FragmentTags.USER_PROFILE)
          .commit();
    } else {
      mBookPosition = savedInstanceState.getInt(Keys.BOOK_POSITION);
    }

    loadBookSearchResults();

    return view;
  }
예제 #22
0
  private void initView() {
    mCurrentTabIndex = 0;
    mTabTitles =
        new String[] {
          mActivity.getResources().getString(R.string.ml_chat),
          mActivity.getResources().getString(R.string.ml_contacts),
          mActivity.getResources().getString(R.string.ml_test)
        };

    mContactsFragment = MLContactsFragment.newInstance();
    mConversationFragment = MLConversationsFragment.newInstance();
    mTestFragment = MLTestFragment.newInstance();

    mFragments = new Fragment[] {mConversationFragment, mContactsFragment, mTestFragment};
    MLViewPagerAdapter adapter =
        new MLViewPagerAdapter(getSupportFragmentManager(), mFragments, mTabTitles);
    mViewPager.setAdapter(adapter);
    mViewPager.setCurrentItem(mCurrentTabIndex);
    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            getToolbar().setTitle(mTabTitles[position]);
          }

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

    mTabLayout.setupWithViewPager(mViewPager);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_viewpagerdemo);
   viewPager = (ViewPager) findViewById(R.id.viewPager);
   viewPager.setAdapter(adapter);
 }
예제 #24
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.guide_activity);
   setUpViews();
   viewPager.setAdapter(adapter);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpager);

    mViewPager = (ViewPager) findViewById(R.id.v_scroll);
    StickHeaderLayout shl_root = (StickHeaderLayout) findViewById(R.id.shl_root);
    mViewPager.setOffscreenPageLimit(4);

    manager = new StickHeaderViewPagerManager(shl_root, mViewPager);

    viewList = new ArrayList<ViewPagerBean>();

    SimpleRecyclerView simpleRecyclerView = new SimpleRecyclerView(this);
    viewList.add(
        new ViewPagerBean(simpleRecyclerView, simpleRecyclerView.getPlaceHoderHeaderLayout()));

    SimpleScrollView simpleScrollView = new SimpleScrollView(this);
    viewList.add(new ViewPagerBean(simpleScrollView, simpleScrollView.getPlaceHoderHeaderLayout()));

    SimpleListView simpleListView = new SimpleListView(this);
    viewList.add(new ViewPagerBean(simpleListView, simpleListView.getPlaceHoderHeaderLayout()));

    SimpleWebView simpleWebView = new SimpleWebView(this);
    viewList.add(new ViewPagerBean(simpleWebView, simpleWebView.getPlaceHoderHeaderLayout()));

    mViewPager.setAdapter(pagerAdapter);

    initTabBar();
  }
  private void setupViewPager(ViewPager viewPager) {

    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFragment(new View_Content_Category(), "View");
    adapter.addFragment(new List_Content_Category(), "List");
    viewPager.setAdapter(adapter);
  }
예제 #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //
    ButterKnife.bind(this);
    getSupportActionBar().hide();
    final ViewPagerAdapter adap = new ViewPagerAdapter(getSupportFragmentManager());
    viewpager.setAdapter(adap);
    viewpager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            updateTotal(position, PIC_LINKS.length);
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
    updateTotal(0, PIC_LINKS.length);
  }
예제 #28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_touristic_point);

    // Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setSubtitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);

    // Create the adapter that will return a fragment for each of the sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.addOnPageChangeListener(this);

    // Tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Recebendo dados da outra activity
    Intent intent = getIntent();
    int id = intent.getExtras().getInt("id");
    touristicPoint = DatabaseDAO.getInstance().getTouristicPointByID(id);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_weather_pager);

    UUID weatherId = (UUID) getIntent().getSerializableExtra(WEATHER_FORECAST_ID);

    mViewPager = (ViewPager) findViewById(R.id.activity_weather_pager_view_pager);

    mWeather = WeatherStation.get(this).getWeather();
    FragmentManager fragmentManager = getSupportFragmentManager();
    mViewPager.setAdapter(
        new FragmentStatePagerAdapter(fragmentManager) {

          @Override
          public Fragment getItem(int position) {
            Weather weather = mWeather.get(position);
            return WeatherDetailsFragment.newInstance(weather.getId());
          }

          @Override
          public int getCount() {
            return mWeather.size();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    savedInstanceState = getIntent().getExtras().getBundle("bundle");
    this.tab = savedInstanceState.getStringArrayList("list");
    this.pos = savedInstanceState.getInt("position");
    setContentView(R.layout.activity_town_details);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2);
    setSupportActionBar(toolbar);

    ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);

    refresh();
    List<TownDetailsFragment> list = new ArrayList<TownDetailsFragment>();
    for (int i = 0; i < this.tab.size(); i++) {
      list.add(TownDetailsFragment.newInstance(this.tab.get(i)));
    }

    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager(), list);
    this.receiverData = new RefreshAllReceiver(pagerAdapter, this.tab);
    this.receiverIcon = new RefreshIconReceiver(pagerAdapter);
    this.filtreData = new IntentFilter("com.intent.action.ALLRECEIVE");
    this.filtreIcon = new IntentFilter("com.intent.action.ICON_UPDATE");

    this.registerReceiver(receiverData, filtreData);
    this.registerReceiver(receiverIcon, filtreIcon);

    refresh();
    ViewPager view = (ViewPager) findViewById(R.id.viewpager);
    view.setAdapter(pagerAdapter);
    view.setCurrentItem(pos);
  }