android.support.v4.view.ViewPager Java Examples
The following examples show how to use
android.support.v4.view.ViewPager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnderlinePageIndicator.java From iMoney with Apache License 2.0 | 6 votes |
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mCurrentPage = position; mPositionOffset = positionOffset; if (mFades) { if (positionOffsetPixels > 0) { removeCallbacks(mFadeRunnable); mPaint.setAlpha(0xFF); } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) { postDelayed(mFadeRunnable, mFadeDelay); } } invalidate(); if (mListener != null) { mListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } }
Example #2
Source File: HollyViewPager.java From HollyViewPager with Apache License 2.0 | 6 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); addView(LayoutInflater.from(getContext()).inflate(R.layout.holly_view_pager, this, false)); viewPager = (ViewPager) findViewById(R.id.bfp_viewPager); headerScroll = (HorizontalScrollView) findViewById(R.id.bfp_headerScroll); headerLayout = (ViewGroup) findViewById(R.id.bfp_headerLayout); { ViewGroup.LayoutParams layoutParams = headerLayout.getLayoutParams(); layoutParams.height = this.settings.headerHeightPx; headerLayout.setLayoutParams(layoutParams); } animator = new HollyViewPagerAnimator(this); }
Example #3
Source File: PlayerAdapter.java From IdealMedia with Apache License 2.0 | 6 votes |
public TrackViewHolder(View view) { super(view); index = (CircularProgressButton) view.findViewById(R.id.cell_index); artist = (TextView) view.findViewById(R.id.cell_artist); title = (TextView) view.findViewById(R.id.cell_title); duration = (TextView) view.findViewById(R.id.cell_duration); textSearchAuthor = (TextView) view.findViewById(R.id.textSearchAuthor); actionSetRingtone = view.findViewById(R.id.actionSetRingtone); actionShare = view.findViewById(R.id.actionShare); actionSearchArtist = view.findViewById(R.id.actionSearchAuthor); actionDownload = view.findViewById(R.id.actionDownload); actionToPlaylist = view.findViewById(R.id.actionToPlaylist); actionFromPlaylist = view.findViewById(R.id.actionFromPlaylist); artwork = (ImageView) view.findViewById(R.id.cell_artwork); downloadProgress = (CircularProgressButton) view.findViewById(R.id.track_cell_progress_download); viewPager = (ViewPager) view.findViewById(R.id.viewPager); mainView = viewPager.findViewById(R.id.item_page_0); }
Example #4
Source File: AboutUsPagerFragment.java From barterli_android with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { init(container, savedInstanceState); setHasOptionsMenu(true); setActionBarTitle(getString(R.string.Aboutus_fragment_title)); final View view = inflater .inflate(R.layout.fragment_aboutus_pager, container, false); mTitles= new ArrayList<String>(Arrays.asList(getResources().getStringArray(R.array.aboutus_fragment_titles))); mAboutUsPager = (ViewPager) view.findViewById(R.id.pager_aboutus); mAdapter = new AboutUsPageAdapter(getChildFragmentManager(), mTitles); mAboutUsPager.setAdapter(mAdapter); mIndicator = (TitlePageIndicator) view .findViewById(R.id.aboutUsTitlesIndicator); mIndicator.setOnPageChangeListener(this); mIndicator.setViewPager(mAboutUsPager); onPageSelected(0); return view; }
Example #5
Source File: UnderlinePageIndicator.java From Huochexing12306 with Apache License 2.0 | 6 votes |
@Override public void setViewPager(ViewPager viewPager) { if (mViewPager == viewPager) { return; } if (mViewPager != null) { //Clear us from the old pager. mViewPager.setOnPageChangeListener(null); } if (viewPager.getAdapter() == null) { throw new IllegalStateException("ViewPager does not have adapter instance."); } mViewPager = viewPager; mViewPager.setOnPageChangeListener(this); invalidate(); post(new Runnable() { @Override public void run() { if (mFades) { post(mFadeRunnable); } } }); }
Example #6
Source File: CommentsTimeLinePagerAdapter.java From iBeebo with GNU General Public License v3.0 | 6 votes |
public CommentsTimeLinePagerAdapter(CommentsTimeLineFragment fragment, ViewPager viewPager, FragmentManager fm, SparseArray<Fragment> fragmentList) { super(fm); this.fragmentList = fragmentList; fragmentList.append(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION, fragment.getCommentsToMeTimeLineFragment()); fragmentList.append(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION, fragment.getCommentsByMeTimeLineFragment()); FragmentTransaction transaction = fragment.getChildFragmentManager().beginTransaction(); if (!fragmentList.get(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION).isAdded()) transaction.add(viewPager.getId(), fragmentList.get(CommentsTimeLineFragment.COMMENTS_TO_ME_CHILD_POSITION), CommentsToMeTimeLineFragment.class.getName()); if (!fragmentList.get(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION).isAdded()) transaction.add(viewPager.getId(), fragmentList.get(CommentsTimeLineFragment.COMMENTS_BY_ME_CHILD_POSITION), CommentsByMeTimeLineFragment.class.getName()); if (!transaction.isEmpty()) { transaction.commit(); fragment.getChildFragmentManager().executePendingTransactions(); } }
Example #7
Source File: RoundCornerIndicaor.java From FlycoPageIndicator with MIT License | 6 votes |
@Override public void setViewPager(ViewPager vp, int realCount) { if (isValid(vp)) { this.vp = vp; this.count = realCount; vp.removeOnPageChangeListener(this); vp.addOnPageChangeListener(this); unselectDrawables.clear(); unselectRects.clear(); for (int i = 0; i < count; i++) { unselectDrawables.add(new GradientDrawable()); unselectRects.add(new Rect()); } invalidate(); } }
Example #8
Source File: XBannerViewPager.java From XBanner with Apache License 2.0 | 6 votes |
private float getXVelocity() { float xVelocity = 0; Class viewpagerClass = ViewPager.class; try { Field velocityTrackerField = viewpagerClass.getDeclaredField("mVelocityTracker"); velocityTrackerField.setAccessible(true); VelocityTracker velocityTracker = (VelocityTracker) velocityTrackerField.get(this); Field activePointerIdField = viewpagerClass.getDeclaredField("mActivePointerId"); activePointerIdField.setAccessible(true); Field maximumVelocityField = viewpagerClass.getDeclaredField("mMaximumVelocity"); maximumVelocityField.setAccessible(true); int maximumVelocity = maximumVelocityField.getInt(this); velocityTracker.computeCurrentVelocity(1000, maximumVelocity); xVelocity = VelocityTrackerCompat.getXVelocity(velocityTracker, activePointerIdField.getInt(this)); } catch (Exception ignored) { } return xVelocity; }
Example #9
Source File: UnderlinePageIndicator.java From android-project-wo2b with Apache License 2.0 | 6 votes |
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mCurrentPage = position; mPositionOffset = positionOffset; if (mFades) { if (positionOffsetPixels > 0) { removeCallbacks(mFadeRunnable); mPaint.setAlpha(0xFF); } else if (mScrollState != ViewPager.SCROLL_STATE_DRAGGING) { postDelayed(mFadeRunnable, mFadeDelay); } } invalidate(); if (mListener != null) { mListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } }
Example #10
Source File: MainBottomTabLayout.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
private void setViewPager(ViewPager viewPager) { removeAllViews(); mViewPager = viewPager; if (viewPager != null && viewPager.getAdapter() != null) { viewPager.setOnPageChangeListener(new InternalViewPagerListener()); initTabLayout(); viewPager.setCurrentItem(0); // for (int i : justBottonPosition) { // tabItemsNoJustButtonPosition.remove(i); // viewPagerAllPosition.add(i, i); // } for (int i = 0; i < justBottonPosition.size(); i++) { int j = justBottonPosition.get(i); tabItemsNoJustButtonPosition.remove(j - i); viewPagerAllPosition.add(j, j); } } }
Example #11
Source File: ActionBarTabsPager.java From V.FlyoutTest with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
Example #12
Source File: HomeFragment.java From letv with Apache License 2.0 | 6 votes |
private void findView() { this.myViewPager = (ViewPager) this.mRootView.findViewById(R.id.channel_detail_viewpager); this.mTabPageIndicator = (ChannelTabPageIndicator) this.mRootView.findViewById(R.id.channel_detail_indicator); this.mChannelWallIcon = (RelativeLayout) this.mRootView.findViewById(R.id.channel_wall_icon); this.mViewshadow = this.mRootView.findViewById(R.id.channel_wall_shadow); this.mChannelWallIcon.setOnClickListener(new OnClickListener(this) { final /* synthetic */ HomeFragment this$0; { if (HotFix.PREVENT_VERIFY) { System.out.println(VerifyLoad.class); } this.this$0 = this$0; } public void onClick(View v) { this.this$0.startChannelWallActivity(); } }); this.myViewPager.setOnTouchListener(this.onTouchListener); this.mRootView.setOnTouchListener(this.onTouchListener); this.mRootView.loading(false); this.mViewshadow.bringToFront(); }
Example #13
Source File: SlidingTabLayout.java From android-common-utils with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (mScrollState == ViewPager.SCROLL_STATE_IDLE) { mTabStrip.onViewPagerPageChanged(position, 0f); scrollToTab(position, 0); } if (mViewPagerPageChangeListener != null) { mViewPagerPageChangeListener.onPageSelected(position); } if(mSelectPosition != position) mSelectPosition = position; }
Example #14
Source File: CirclePageIndicator.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (mSnap || mScrollState == ViewPager.SCROLL_STATE_IDLE) { mCurrentPage = position; mSnapPage = position; invalidate(); } if (mListener != null) { mListener.onPageSelected(position); } }
Example #15
Source File: MainActivity.java From HomeApplianceMall with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.ViewPager_main); radioGroup = (RadioGroup) findViewById(R.id.RadioGroup_main); application = (MyApplication)getApplication(); //viewPage List<Fragment> fragmentList = new ArrayList<>(); HomeFragment homeFragment = new HomeFragment(); SearchFragment searchFragment = new SearchFragment(); ClassifyFragment classifyFragment = new ClassifyFragment(); ShoppingCarFragment shoppingCarFragment = new ShoppingCarFragment(); OrderFragment orderFragment = new OrderFragment(); MyFragment myFragment = new MyFragment(); fragmentList.add(homeFragment); fragmentList.add(searchFragment); fragmentList.add(classifyFragment); fragmentList.add(shoppingCarFragment); fragmentList.add(orderFragment); fragmentList.add(myFragment); application.setViewPager(viewPager); viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(),fragmentList)); viewPager.setCurrentItem(0); viewPager.setOnPageChangeListener(new MyPageLister()); // radioGroup.setOnCheckedChangeListener(new MyRadionGroupListen()); radioGroup.check(R.id.radioButton_main_home); // }
Example #16
Source File: ExploreListAdapter.java From C9MJ with Apache License 2.0 | 5 votes |
@Override public void onPageScrollStateChanged(int state) { switch (state) { case ViewPager.SCROLL_STATE_DRAGGING: isAutoScrolled = false; break; case ViewPager.SCROLL_STATE_SETTLING: isAutoScrolled = false; break; case ViewPager.SCROLL_STATE_IDLE: isAutoScrolled = true; break; } }
Example #17
Source File: FeedsActivity.java From friendlypix-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_feeds); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ViewPager viewPager = (ViewPager) findViewById(R.id.feeds_view_pager); FeedsPagerAdapter adapter = new FeedsPagerAdapter(getSupportFragmentManager()); adapter.addFragment(PostsFragment.newInstance(PostsFragment.TYPE_HOME), "HOME"); adapter.addFragment(PostsFragment.newInstance(PostsFragment.TYPE_FEED), "FEED"); viewPager.setAdapter(adapter); viewPager.setCurrentItem(1); TabLayout tabLayout = (TabLayout) findViewById(R.id.feeds_tab_layout); tabLayout.setupWithViewPager(viewPager); mFab = (FloatingActionButton) findViewById(R.id.fab); mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null || user.isAnonymous()) { Toast.makeText(FeedsActivity.this, "You must sign-in to post.", Toast.LENGTH_SHORT).show(); return; } Intent newPostIntent = new Intent(FeedsActivity.this, NewPostActivity.class); startActivity(newPostIntent); } }); }
Example #18
Source File: AddHotAddressActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void initView() { tbtnHDAccount = (ToggleButton) findViewById(R.id.tbtn_hd_account); tbtnOther = (ToggleButton) findViewById(R.id.tbtn_other); pager = (ViewPager) findViewById(R.id.pager); ibtnCancel = (ImageButton) findViewById(R.id.ibtn_cancel); tbtnHDAccount.setOnClickListener(new IndicatorClick(0)); tbtnOther.setOnClickListener(new IndicatorClick(1)); ibtnCancel.setOnClickListener(cancelClick); pager.setAdapter(adapter); pager.setOnPageChangeListener(pageChange); pager.setCurrentItem(0); tbtnHDAccount.setChecked(true); }
Example #19
Source File: MainActivity.java From ParallaxViewPagers with Apache License 2.0 | 5 votes |
@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)); }
Example #20
Source File: ParentFragment.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
private void initUI(ParsedModel parsed) { m_Title = parsed.getTitle(); setTitle(m_Title); App.getInstance().getTabByTag(getTag()).setTitle(m_Title); getMainActivity().notifyTabAdapter(); viewPager = (ViewPager) findViewById(R.id.devDbViewPager); adapter = new DevDbViewPagerAdapter(getMainActivity(), getChildFragmentManager(), parsed); viewPager.setAdapter(adapter); viewPager.setOnPageChangeListener(mChangeListener); tabLayout.removeAllTabs(); tabLayout.setupWithViewPager(viewPager); showTabs(m_Position); }
Example #21
Source File: PagerViewStrip.java From android-atleap with Apache License 2.0 | 5 votes |
/** * Set ViewPager * @param viewPager ViewPager */ public void setViewPager(ViewPager viewPager) { if (viewPager.getAdapter() == null) { throw new IllegalStateException("ViewPager has to have adapter"); } if (!(viewPager.getAdapter() instanceof TabPagerAdapter)) { throw new IllegalStateException("Adapter has to implement TabPagerAdapter interface"); } mViewPager = viewPager; mViewPager.setOnPageChangeListener(new InternalPageChangeListener()); refreshData(0); }
Example #22
Source File: PagerSlidingTabStrip.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setViewPager(ViewPager pager) { this.pager = pager; if (pager.getAdapter() == null) { throw new IllegalStateException("ViewPager does not have adapter instance."); } pager.setOnPageChangeListener(pageListener); notifyDataSetChanged(); }
Example #23
Source File: SlidingTabLayout.java From views-widgets-samples with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (mScrollState == ViewPager.SCROLL_STATE_IDLE) { mTabStrip.onViewPagerPageChanged(position, 0f); scrollToTab(position, 0); } if (mViewPagerPageChangeListener != null) { mViewPagerPageChangeListener.onPageSelected(position); } }
Example #24
Source File: PagerTabsActivity.java From CoordinatorLayoutSample with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pager_tabs); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); ViewPager pager = (ViewPager) findViewById(R.id.pager); PagerTitleAdapter pagerAdapter = new PagerTitleAdapter(this); pager.setAdapter(pagerAdapter); TabLayout pagerTabs = (TabLayout) findViewById(R.id.pager_tabs); pagerTabs.setupWithViewPager(pager); }
Example #25
Source File: SlidingTabLayout.java From android-SlidingTabsColors with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (mScrollState == ViewPager.SCROLL_STATE_IDLE) { mTabStrip.onViewPagerPageChanged(position, 0f); scrollToTab(position, 0); } if (mViewPagerPageChangeListener != null) { mViewPagerPageChangeListener.onPageSelected(position); } }
Example #26
Source File: TabsAdapter.java From android-open-project-demo with Apache License 2.0 | 5 votes |
public TabsAdapter(MainActivity context, ViewPager viewPager) { super(context.getSupportFragmentManager()); mContext = context; mViewPager = viewPager; mActionBar=context.getSupportActionBar(); mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); }
Example #27
Source File: CirclePageIndicator.java From monolog-android with MIT License | 5 votes |
@Override public void onPageSelected(int position) { if (mSnap || mScrollState == ViewPager.SCROLL_STATE_IDLE) { mCurrentPage = position; mSnapPage = position; invalidate(); } if (mListener != null) { mListener.onPageSelected(position); } }
Example #28
Source File: NewMainActivity.java From Cybernet-VPN with GNU General Public License v3.0 | 5 votes |
private void setupViewPager(ViewPager viewPager) { ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); adapter.addFragment(new MainFragment(), "CONNECTION"); adapter.addFragment(new ContactActivityFragment2(), "NEED HELP?"); adapter.addFragment(new IpDetailsFragment(), "MY IP"); viewPager.setAdapter(adapter); }
Example #29
Source File: MainActivity.java From AndroidDesignPatterns with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Initialize VIewPager ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPager_Home); TabLayout mTabLayout = (TabLayout) findViewById(R.id.tabLayout_Home); MyViewPagerAdapter myViewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(myViewPagerAdapter); //Sync TabLayout with ViewPager. mTabLayout.setupWithViewPager(mViewPager); }
Example #30
Source File: SlidingTabLayout.java From slidingtabs with Apache License 2.0 | 5 votes |
@Override public void onPageSelected(int position) { if (mScrollState == ViewPager.SCROLL_STATE_IDLE) { mTabStrip.onViewPagerPageChanged(position, 0f); scrollToTab(position, 0); } for (int i = 0; i < mTabStrip.getChildCount(); i++) { mTabStrip.getChildAt(i).setSelected(position == i); } if (mViewPagerPageChangeListener != null) { mViewPagerPageChangeListener.onPageSelected(position); } }