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


Java FragmentPagerAdapter类代码示例

本文整理汇总了Java中android.support.v13.app.FragmentPagerAdapter的典型用法代码示例。如果您正苦于以下问题:Java FragmentPagerAdapter类的具体用法?Java FragmentPagerAdapter怎么用?Java FragmentPagerAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createAdapter

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
private PagerAdapter createAdapter() {
    return new FragmentPagerAdapter(getFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0: return QuizFragment.newInstance();
                case 1: return FiltersFragment.newInstance();
                case 2: return MatchesFragment.newInstance();
                case 3: return MyProfileFragment.newInstance();
                case 4: return SettingsFragment.newInstance();
                default: return null;
            }
        }

        @Override
        public int getCount() {
            return 5;
        }
    };
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:21,代码来源:MainActivity.java

示例2: setFragmentAdapter

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
public void setFragmentAdapter(@NonNull FragmentPagerAdapter adapter,
                               @NonNull FragmentManager fm) {
    mOriginalAdapter = adapter;
    mInternalFragmentPagerAdapter = new InternalFragmentPagerAdapter(fm);

    super.setAdapter(mInternalFragmentPagerAdapter);
    mCurrentPosition = mOriginalAdapter.getCount() * 3 / 2;
    super.setCurrentItem(mOriginalAdapter.getCount() * 3 / 2, false);

    addOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int state) {
            if (state == SCROLL_STATE_IDLE) {
                int size = mOriginalAdapter.getCount();
                if (mCurrentPosition < size / 2 + size % 2) {
                    mInternalFragmentPagerAdapter.shiftIndex(false);
                } else if (mCurrentPosition > size * 2 + size / 2) {
                    mInternalFragmentPagerAdapter.shiftIndex(true);
                }
            }
        }
    });
}
 
开发者ID:sanyuzhang,项目名称:CircularViewPager,代码行数:24,代码来源:CircularViewPager.java

示例3: getScrollY

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
public int getScrollY()
{
	IKlyphFragment f = (IKlyphFragment) ((FragmentPagerAdapter) getPagerAdapter()).getItem(getViewPager().getCurrentItem());

	if (f == null || f.getListView() == null)
		return 0;

	listPadding = f.getListView().getPaddingTop();

	View c = f.getListView().getChildAt(0);
	if (c == null)
	{
		return 0;
	}

	int firstVisiblePosition = f.getListView().getFirstVisiblePosition();
	int top = c.getTop();

	int headerHeight = 0;
	if (firstVisiblePosition >= 1)
	{
		headerHeight = fakeHeaderHeight;
	}
	// Log.d("UserActivity", "getScrollY: " + top + " " + headerHeight);
	return -top + firstVisiblePosition * c.getHeight() + headerHeight + listPadding;
}
 
开发者ID:jonathangerbaud,项目名称:Klyph,代码行数:27,代码来源:ProfileActivity.java

示例4: onCreate

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);
	setContentView(R.layout.detail_activity);

	Intent intent = getIntent();
	list = (ArrayList<Item>) intent.getSerializableExtra(KEY_LIST);

	fragments = new ArrayList<DetailFragment>();
	for (Item item : list) {
		fragments.add(new DetailFragment(item));
	}

	final ViewPager pager = (ViewPager) findViewById(R.id.pager);
	pager.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {
		@Override
		public int getCount() {
			return list.size();
		}

		@Override
		public Fragment getItem(int position) {
			// return new DetailFragment(list.get(position));
			return fragments.get(position);
			// return new LabelListFragment(DummyGenerator.getLabelList());
		}
	});
	pager.setCurrentItem(intent.getIntExtra(KEY_POSITION, 0));

	ActionBar actionBar = getActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);
}
 
开发者ID:dekrandroid,项目名称:android-in-sette-giorni,代码行数:34,代码来源:DetailActivity.java

示例5: getPagerAdapter

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
	if (adapter == null)
		adapter = new TabsAdapter(getFragmentManager(), getViewPager());

	return adapter;
}
 
开发者ID:jonathangerbaud,项目名称:Klyph,代码行数:9,代码来源:AlbumActivity.java

示例6: getPagerAdapter

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
	if (adapter == null)
		adapter = new TabsAdapter(this, getFragmentManager(), getPageIndicator());

	return adapter;
}
 
开发者ID:jonathangerbaud,项目名称:Klyph,代码行数:9,代码来源:UserActivity.java

示例7: onCreate

import android.support.v13.app.FragmentPagerAdapter; //导入依赖的package包/类
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_viewpager);
		
		FragmentPagerAdapter adapter = new FragmentPagerAdapter(getFragmentManager()) {
			@Override
			public Fragment getItem(int position) {
				switch (position) {
				case 0:
					return MainFragment.getInstance();
				case 1:
					return MovingFragment.getInstance();
				case 2:
					return BehaviorFragment.getInstance();
				case 3:
					return OverlayFragment.getInstance();
//				case 2:
//					return TestingActivity.getInstance();
				}
				return new Fragment();
			}
			
			@Override
			public String getPageTitle(int pos) {
				switch (pos) {
				case 0:
					return getResources().getString(R.string.pref_main_top_title);
				case 1:
					return getResources().getString(R.string.pref_movable_top_title);
				case 2:
					return getResources().getString(R.string.pref_behavior_title);
				case 3:
					return getResources().getString(R.string.pref_overlay_title);
//				case 2:
//					return getResources().getString(R.string.pref_testing_top_title);
				}
				return "";
			}
			
			@Override
			public int getCount() {
				return 4;
			}
		};
		ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
		viewPager.setAdapter(adapter);
		
		PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip);
		pts.setTabIndicatorColor(0xFF333333);
		pts.setTextColor(0xFF111111);
		pts.setBackgroundColor(Color.TRANSPARENT);
		
		ActionBar bar = getActionBar();
		bar.setBackgroundDrawable(new ColorDrawable(0xFFAA0000)); 
		
		
		testSettings(true);
		
	}
 
开发者ID:shooash,项目名称:XHFW3,代码行数:62,代码来源:MainPreference.java


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