当前位置: 首页>>代码示例>>Java>>正文


Java ViewPager.SimpleOnPageChangeListener方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewPager.SimpleOnPageChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.SimpleOnPageChangeListener方法的具体用法?Java ViewPager.SimpleOnPageChangeListener怎么用?Java ViewPager.SimpleOnPageChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewPager的用法示例。


在下文中一共展示了ViewPager.SimpleOnPageChangeListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EncryptViewModel

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public EncryptViewModel(final Context context, FragmentManager fragmentManager) {
    pagerAdapter = new EncryptPagerAdapter(context, fragmentManager);
    pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            drawableDot1.set(context.getResources().getDrawable(position == 0 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot2.set(context.getResources().getDrawable(position == 1 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
            drawableDot3.set(context.getResources().getDrawable(position == 2 ? R.drawable.selecteditem_dot : R.drawable.nonselecteditem_dot));
        }

    };

    drawableDot1 = new ObservableField<>(context.getResources().getDrawable(R.drawable.selecteditem_dot));
    drawableDot2 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
    drawableDot3 = new ObservableField<>(context.getResources().getDrawable(R.drawable.nonselecteditem_dot));
}
 
开发者ID:tresorit,项目名称:ZeroKit-Android-SDK,代码行数:18,代码来源:EncryptViewModel.java

示例2: initViewPager

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initViewPager() {
	mPagerAdapter = new EditBuildPagerAdapter(getSupportFragmentManager(), this, mInitialBuild, this);
	mPager.setOffscreenPageLimit(3);
	mPager.setAdapter(mPagerAdapter);
	final ViewPager.OnPageChangeListener onPageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
           @Override
           public void onPageSelected(int position) {
               // Show or hide floating Add button depending on current tab's preference
               setAddButtonVisibility(getCurrentlyVisibleEditorTab().requestsAddButton());
           }
       };
	mPager.addOnPageChangeListener(onPageChangeListener);

	mTabLayout.setupWithViewPager(mPager);
}
 
开发者ID:kiwiandroiddev,项目名称:starcraft-2-build-player,代码行数:16,代码来源:EditBuildActivity.java

示例3: initializeViewPager

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initializeViewPager() {
    if (mAlbumFiles != null) {
        if (mAlbumFiles.size() > 3)
            mViewPager.setOffscreenPageLimit(3);
        else if (mAlbumFiles.size() > 2)
            mViewPager.setOffscreenPageLimit(2);
    }

    BasicPreviewAdapter previewAdapter = new AlbumFilePreviewAdapter(getContext(), mAlbumFiles);
    mViewPager.setAdapter(previewAdapter);
    ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mCurrentItemPosition = position;
            AlbumFile albumFile = mAlbumFiles.get(mCurrentItemPosition);
            mCheckBox.setChecked(albumFile.isChecked());
            mCheckBox.setEnabled(albumFile.isEnable());
            setTitle(mCurrentItemPosition + 1 + " / " + mAlbumFiles.size());

            if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
                mTvDuration.setText(AlbumUtils.convertDuration(albumFile.getDuration()));
                mTvDuration.setVisibility(View.VISIBLE);
            } else {
                mTvDuration.setVisibility(View.GONE);
            }

            mLayoutLayer.setVisibility(albumFile.isEnable() ? View.GONE : View.VISIBLE);
        }
    };
    mViewPager.addOnPageChangeListener(pageChangeListener);
    mViewPager.setCurrentItem(mCurrentItemPosition);
    // Forced call.
    pageChangeListener.onPageSelected(mCurrentItemPosition);
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:35,代码来源:AlbumPreviewFragment.java


注:本文中的android.support.v4.view.ViewPager.SimpleOnPageChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。