java类android.support.v4.view.ViewPager的实例源码

DetailActivity.java 文件源码 项目:android-instant-apps 阅读 22 收藏 0 点赞 0 评论 0
private void setUpViewPager(ArrayList<Photo> photos) {
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new DetailViewPagerAdapter(this, photos, sharedElementCallback));
    viewPager.setCurrentItem(initialItem);

    viewPager.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                                   int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (viewPager.getChildCount() > 0) {
                viewPager.removeOnLayoutChangeListener(this);
                startPostponedEnterTransition();
            }
        }
    });

    viewPager.setPageMargin(getResources().getDimensionPixelSize(
            com.example.android.unsplash.base.R.dimen.padding_mini));
    viewPager.setPageMarginDrawable(R.drawable.page_margin);
}
MoviesGridActivity.java 文件源码 项目:mdb-android-application 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    setTabLayoutListener();
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    initTabIcons();
    //default position
    viewPager.setCurrentItem(1);
}
TutoriasActivity.java 文件源码 项目:ConnectU 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_tutorias);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) this.getApplication();
    //SetView
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    tabLayout = (TabLayout) findViewById(R.id.tabs);
    progress = (AVLoadingIndicatorView) findViewById(R.id.material_progress);
    title = (TextView) findViewById(R.id.toolbar_title);
    fabTut = (FloatingActionButton) findViewById(R.id.fabTut);
    setYearAdapters();
    request = new TutoriasRequest(this);
    updateYear(true, app.getPublicPreferenceI(Common.GLOBAL_FILTER_YEAR));
    doRequest();
}
DayPickerView.java 文件源码 项目:DateTimePicker 阅读 31 收藏 0 点赞 0 评论 0
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final ViewPager viewPager = mViewPager;
    measureChild(viewPager, widthMeasureSpec, heightMeasureSpec);

    final int measuredWidthAndState = viewPager.getMeasuredWidthAndState();
    final int measuredHeightAndState = viewPager.getMeasuredHeightAndState();
    setMeasuredDimension(measuredWidthAndState, measuredHeightAndState);

    final int pagerWidth = viewPager.getMeasuredWidth();
    final int pagerHeight = viewPager.getMeasuredHeight();
    final int buttonWidthSpec = MeasureSpec.makeMeasureSpec(pagerWidth, MeasureSpec.AT_MOST);
    final int buttonHeightSpec = MeasureSpec.makeMeasureSpec(pagerHeight, MeasureSpec.AT_MOST);
    mPrevButton.measure(buttonWidthSpec, buttonHeightSpec);
    mNextButton.measure(buttonWidthSpec, buttonHeightSpec);
}
YViewPagerNew.java 文件源码 项目:YViewPagerDemo 阅读 24 收藏 0 点赞 0 评论 0
private void dispatchOnPageScrolled(int position, float offset, int offsetPixels) {
    int newPosition = isCirculatory ? position % mAdapter.getCount() : position;
    if (mOnPageChangeListener != null) {
        mOnPageChangeListener.onPageScrolled(newPosition, offset, offsetPixels);
    }
    if (mOnPageChangeListeners != null) {
        for (int i = 0, z = mOnPageChangeListeners.size(); i < z; i++) {
            ViewPager.OnPageChangeListener listener = mOnPageChangeListeners.get(i);
            if (listener != null) {
                listener.onPageScrolled(newPosition, offset, offsetPixels);
            }
        }
    }
    if (mInternalPageChangeListener != null) {
        mInternalPageChangeListener.onPageScrolled(newPosition, offset, offsetPixels);
    }
}
UnderlinePageIndicator.java 文件源码 项目:GitHub 阅读 47 收藏 0 点赞 0 评论 0
@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);
            }
        }
    });
}
ScrollableTabExampleActivity.java 文件源码 项目:GitHub 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrollable_indicator_example_layout);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(mExamplePagerAdapter);

    initMagicIndicator1();
    initMagicIndicator2();
    initMagicIndicator3();
    initMagicIndicator4();
    initMagicIndicator5();
    initMagicIndicator6();
    initMagicIndicator7();
    initMagicIndicator8();
    initMagicIndicator9();
}
LinePageIndicator.java 文件源码 项目:android-project-gallery 阅读 20 收藏 0 点赞 0 评论 0
@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();
}
EnglishActivity.java 文件源码 项目:AndroidApp-Deploy 阅读 21 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_english);

    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, "Aspe", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

}
PostulacionesActivasActivity.java 文件源码 项目:changApp 阅读 27 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_postulaciones_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_pa);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerpa);
    // Adding menu icon to Toolbar
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        supportActionBar.setHomeAsUpIndicator(indicator);
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }

}
SocialActivity.java 文件源码 项目:cat-is-a-dog 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Create the tabs and instantiate the social tabs
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_social);
    drawToolbar();

    ViewPager viewPager = (ViewPager) findViewById(R.id.socialPager);
    adapter = new ViewPagerAdapter(getSupportFragmentManager());

    adapter.addFragment(new FollowingFragment(), "Following");
    adapter.addFragment(new FollowersFragment(), "Followers");
    adapter.addFragment(new FollowRequestsFragment(), "Requests");
    adapter.addFragment(new SearchUsersFragment(), "Search");
    viewPager.setAdapter(adapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.socialTabs);
    tabLayout.setupWithViewPager(viewPager);
}
ViewPagerTabFragmentParentFragment.java 文件源码 项目:GitHub 阅读 20 收藏 0 点赞 0 评论 0
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.simplefragment_viewpaper_fragment_parent, container, false);
    totalfullheight = view.getHeight();
    AppCompatActivity parentActivity = (AppCompatActivity) getActivity();
    mPagerAdapter = new NavigationAdapter(getChildFragmentManager());
    mPager = (ViewPager) view.findViewById(R.id.pager);
    pager_wrapper = (FrameLayout) view.findViewById(R.id.pager_wrapper);
    mPager.setAdapter(mPagerAdapter);
    mHeaderContainer = (View) view.findViewById(R.id.header);
    headerBanner = (ImageView) view.findViewById(R.id.header_background);
    slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);
    ViewConfiguration vc = ViewConfiguration.get(parentActivity);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionLayout) view.findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    mPager.setCurrentItem(0);
    return view;
}
LinePageIndicator.java 文件源码 项目:Huochexing12306 阅读 18 收藏 0 点赞 0 评论 0
@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();
}
NavBarHook.java 文件源码 项目:XposedNavigationBar 阅读 21 收藏 0 点赞 0 评论 0
private static void hookNavBar(ViewGroup rootView, ViewGroup navbarView) {
    rootNavbarView = rootView;
    Context context = rootView.getContext();
    ViewPager vpXpHook = new ViewPager(context);

    exNavbar = new LinearLayout(context);
    musicControllerPanel = new MusicControllerPanel(context);
    onHomeNavbar = new LinearLayout(context);

    initExNavbar(vpXpHook, exNavbar);
    initHomeNavbar(onHomeNavbar, vpXpHook);
    initMusicPanel(musicControllerPanel);
    initVpHook(vpXpHook, navbarView, exNavbar, musicControllerPanel, onHomeNavbar);

    initBroadcast(context);
    initClipBoardListener(context);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
            ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
    rootView.addView(vpXpHook, 0, params);

    setNavbarHeight(context, DataHook.navbarHeight);
}
SwipeBackLayout.java 文件源码 项目:Multi-SwipeBackLayout 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Find out the scrollable child view
 * 这里添加了常用的一些可滑动类,特殊类需要添加
 *
 * @param target targetView
 */
private void findScrollView(ViewGroup target) {
    final int count = target.getChildCount();
    if (count > 0) {
        for (int i = 0; i < count; i++) {
            final View child = target.getChildAt(i);
            if (child instanceof AbsListView
                    || isInstanceOfClass(child, ScrollView.class.getName())
                    || isInstanceOfClass(child, NestedScrollView.class.getName())
                    || isInstanceOfClass(child, RecyclerView.class.getName())
                    || child instanceof HorizontalScrollView
                    || child instanceof ViewPager
                    || child instanceof WebView) {
                mScrollChild = child;
                break;
            } else if (child instanceof ViewGroup) {
                findScrollView((ViewGroup) child);
            }
        }
    }
    if (mScrollChild == null) mScrollChild = target;
}
FragmentActivity.java 文件源码 项目:android_permission 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_activity_layout);

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

    imageFragment = Fragment.instantiate(this, ImageFragment.class.getName());
    textFragment = Fragment.instantiate(this, TextFragment.class.getName());
    image2Fragment = Fragment.instantiate(this, ImageFragment.class.getName());
    text2Fragment = Fragment.instantiate(this, TextFragment.class.getName());

    mViewPager.setOffscreenPageLimit(4);
    mViewPager.setCurrentItem(0);
    mViewPager.setAdapter(new FPagerAdapter(getSupportFragmentManager()));
}
MarathiActivity.java 文件源码 项目:Lang_Tutor 阅读 18 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_marathi);

    // Find the view pager that will allow the user to swipe between fragments
    ViewPager viewPager = (ViewPager) findViewById(R.id.marathi_viewpager);

    // Create an adapter that knows which fragment should be shown on each page
    MarathiCategoryAdapter adapter = new MarathiCategoryAdapter(this,getSupportFragmentManager());

    // Set the adapter onto the view pager
    viewPager.setAdapter(adapter);

    // Find the tab layout that shows the tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.marathi_tabs);

    // Connect the tab layout with the view pager. This will
    //   1. Update the tab layout when the view pager is swiped
    //   2. Update the view pager when a tab is selected
    //   3. Set the tab layout's tab names with the view pager's adapter's titles
    //      by calling onPageTitle()
    tabLayout.setupWithViewPager(viewPager);
}
RefreshContentWrapper.java 文件源码 项目:SmartRefreshLayout 阅读 26 收藏 0 点赞 0 评论 0
protected View findScrollableViewByEvent(View content, MotionEvent event, View orgScrollableView) {
    if (content instanceof ViewGroup && event != null) {
        ViewGroup viewGroup = (ViewGroup) content;
        final int childCount = viewGroup.getChildCount();
        PointF point = new PointF();
        for (int i = childCount; i > 0; i--) {
            View child = viewGroup.getChildAt(i - 1);
            if (isTransformedTouchPointInView(viewGroup, child, event.getX(), event.getY(), point)) {
                if (!(child instanceof ViewPager) && isScrollableView(child)) {
                    return child;
                } else {
                    event = MotionEvent.obtain(event);
                    event.offsetLocation(point.x, point.y);
                    return findScrollableViewByEvent(child, event, orgScrollableView);
                }
            }
        }
    }
    return orgScrollableView;
}
NewsListController.java 文件源码 项目:Readhub-Android 阅读 20 收藏 0 点赞 0 评论 0
public NewsListController(@NonNull Activity activity, @NonNull ViewPager viewPager, @Tab int tab) {
    this.activity = activity;
    contentView = LayoutInflater.from(activity).inflate(R.layout.controller_news_list, viewPager, false);
    ButterKnife.bind(this, contentView);

    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    recyclerView.addItemDecoration(new GapItemDecoration(activity));
    recyclerView.addOnScrollListener(new FloatingTipButtonBehaviorListener.ForRecyclerView(btnBackToTopAndRefresh));

    loadMoreFooter = new LoadMoreFooter(activity, recyclerView, this);

    listAdapter = new NewsListAdapter(activity);
    recyclerView.setAdapter(listAdapter);

    newsListPresenter = new NewsListPresenter(activity, this, tab);

    refreshLayout.setColorSchemeResources(R.color.color_primary);
    refreshLayout.setOnRefreshListener(this);
    refreshLayout.setRefreshing(true);
    onRefresh();
}
BaseViewPagerFragment.java 文件源码 项目:OSchina_resources_android 阅读 18 收藏 0 点赞 0 评论 0
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (mRoot == null) {
        View root = inflater.inflate(R.layout.base_viewpage_fragment, null);

        mTabStrip = (PagerSlidingTabStrip) root
                .findViewById(R.id.pager_tabstrip);

        mViewPager = (ViewPager) root.findViewById(R.id.pager);

        mErrorLayout = (EmptyLayout) root.findViewById(R.id.error_layout);

        mTabsAdapter = new ViewPageFragmentAdapter(getChildFragmentManager(),
                mTabStrip, mViewPager);
        setScreenPageLimit();
        mRoot = root;
        onSetupTabAdapter(mTabsAdapter);
    }
    return mRoot;
}
MainActivity.java 文件源码 项目:TextEmoji 阅读 18 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    initTabList();
    mAdapter = new TabLayoutFragmentAdapter(getSupportFragmentManager(), mTabList, this, mFragments, mTabImgs);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
    mTabLayout.setupWithViewPager(mViewPager);
    mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    for (int i = 0; i < mTabLayout.getTabCount(); i++) {
        mTabLayout.getTabAt(i).setCustomView(mAdapter.getTabView(i));
    }
    mTabLayout.addOnTabSelectedListener(this);
}
MainActivity.java 文件源码 项目:AndroidSkinAnimator 阅读 20 收藏 0 点赞 0 评论 0
private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new FirstFragment());
    list.add(new MiddleFragment());
    list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
    List<String> listTitle = new ArrayList<>();
    listTitle.add("系统组件");
    listTitle.add("自定义View");
    listTitle.add("第三方库控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
ReactViewPager.java 文件源码 项目:RNLearn_Project1 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Remove all the views from the adapter and de-parents them from the ViewPager
 * After calling this, it is expected that notifyDataSetChanged should be called soon
 * afterwards.
 */
void removeAllViewsFromAdapter(ViewPager pager) {
  mViews.clear();
  pager.removeAllViews();
  // set this, so that when the next addViews is called, we return POSITION_NONE for every
  // entry so we can remove whichever views we need to and add the ones that we need to.
  mIsViewPagerInIntentionallyInconsistentState = true;
}
MainActivity.java 文件源码 项目:MorseKnown 阅读 17 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //创建资源
    rc = new ResourcesCompat();

    //创建FRAGMENT  添加tab
    pager = new Pager(getSupportFragmentManager());

    //得到VIEWPAGER
    viewPager = (ViewPager)findViewById(R.id.view_pager);
    viewPager.setAdapter(pager);

    //把TAB 添加到TabLayout上
    TabLayout tabLayout = (TabLayout)findViewById(R.id.tab_layout);

    //设置tab显示的内容
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.getTabAt(0).setText("闪光灯编码");
    tabLayout.getTabAt(3).setText("闪光灯解码");
    tabLayout.getTabAt(2).setText("参数设置 ");
    tabLayout.getTabAt(1).setText("对照表 ");
    tabLayout.getTabAt(4).setText("关于我们");
    viewPager.setOffscreenPageLimit(0);
    //添加导航条颜色
    if(Build.VERSION.SDK_INT >= CUSTOM_TOP_BAR_COLOR_API){
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(rc.getColor(getResources(), R.color.bold, null));
        window.setNavigationBarColor(rc.getColor(getResources(), R.color.dull, null));
    }

}
FixedTabExampleActivity.java 文件源码 项目:GitHub 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fixed_tab_example_layout);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(mExamplePagerAdapter);

    initMagicIndicator1();
    initMagicIndicator2();
    initMagicIndicator3();
    initMagicIndicator4();
}
TabLayoutActivity.java 文件源码 项目:android-advanced-light 阅读 20 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    initViewPager();
}
TicketInfoAty.java 文件源码 项目:Huochexing12306 阅读 21 收藏 0 点赞 0 评论 0
private void initViews() {

    adapter = new TicketInfoFragmentAdapter(getSupportFragmentManager(), this);
    ViewPager pager = (ViewPager)findViewById(R.id.pager);
    pager.setAdapter(adapter);
    TabPageIndicator indicator = (TabPageIndicator)findViewById(R.id.indicator);
    indicator.setViewPager(pager);
}
StickyNavLayout.java 文件源码 项目:CoordinatorLayoutExample-master 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mTop = findViewById(R.id.id_stickynavlayout_topview);
    mNav = findViewById(R.id.id_stickynavlayout_indicator);
    mViewPager = (ViewPager) findViewById(R.id.id_stickynavlayout_viewpager);
}
PageScrollTab.java 文件源码 项目:PageScrollView 阅读 26 收藏 0 点赞 0 评论 0
public void setViewPager(ViewPager pager) {
    mViewPager = pager;
    PagerAdapter adp = pager == null ? null : pager.getAdapter();
    if (adp != null) {
        if (adp instanceof ItemProvider) {
            mITabProvider = (ItemProvider) adp;
        }
        pager.setOnPageChangeListener(mViewPageListener);
    }
    notifyDataSetChanged();
}
MoviePhotoActivity.java 文件源码 项目:MyDemo 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void initViews() {
    mId = getIntent().getStringExtra("movieId");
    mPresenter = new MoviePhotoPresenterImpl(this,mId);
    setSupportActionBar(mToolBar);
    mToolBar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new MoviePhotoPagerAdapter(this);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
        @Override
        public void onPageSelected(int position) {
            MoviePhoto moviePhoto = mAdapter.getItem(position);
            mToolBar.setTitle("电影剧照("+(position+1)+"/"+mAdapter.getCount()+")");
            tvPhotoDate.setText(moviePhoto.getCreated_at());
            tvPhotoDesc.setText(moviePhoto.getDesc());
            tvPhotoUseful.setText(moviePhoto.getRecs_count()+"");
            tvPhotoComment.setText(moviePhoto.getComments_count()+"");
        }
    });
    registerViewShowEvent();
}


问题


面经


文章

微信
公众号

扫码关注公众号