當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。